// Generated by Construct, the game and animation creation tool
// Visit: https://www.construct.net

"use strict";window.i=class{constructor(t,s){this.h=t,this.o=s,this.l=!1,this.u=()=>this.m()}g(){}v(t,s,i,e){this.h._(this.o,t,s,i,e)}S(t,s,i,e){return this.h.O(this.o,t,s,i,e)}P(t,s,i){this.h.C()?this.v(t,s,i):this.h.M()._OnMessageFromDOM({type:"event",component:this.o,handler:t,dispatchOpts:i||null,data:s,responseId:null})}R(t,s){this.h.T(this.o,t,s)}I(t){for(const[s,i]of t)this.R(s,i)}A(){return this.h}G(){return this.o}D(){this.l||(this.h.F(this.u),this.l=!0)}W(){this.l&&(this.h.L(this.u),this.l=!1)}m(){}},window.U=class{constructor(t,s){this.H=t,this.B=s,this.V=-1,this.j=-1/0,this.N=()=>this.$(),this.Y=!1,this.X=!1}J(t){this.X=!!t}K(){if(-1===this.V){const t=Date.now(),s=t-this.j,i=this.B;i<=s&&this.X?(this.j=t,this.Z()):this.V=self.setTimeout(this.N,Math.max(i-s,4))}}Z(){this.Y=!0,this.H(),this.Y=!1}tt(){this.Y||(this.st(),this.j=Date.now())}$(){this.V=-1,this.j=Date.now(),this.Z()}st(){-1!==this.V&&(self.clearTimeout(this.V),this.V=-1)}it(){this.st(),this.H=null,this.N=null}};{class y{constructor(t){this.et=t,this.nt=!1,this.ht=!0,this.ot=-1,this.rt=-1,this.ct=-1}lt(t){this.ht=!!t}ut(){return this.ht}dt(){return this.nt}wt(){this.nt=!0}ft(){return this.ot}yt(t){this.ot=t}gt(){return this.rt}vt(t){this.rt=t}bt(t){this.ct=t}_t(){return this.ct}St(){return this.et}}window.Ot=class extends self.i{constructor(t,s){super(t,s),this.kt=new Map,this.Pt=!0,this.I([["create",t=>this.Ct(t)],["destroy",t=>this.Mt(t)],["set-visible",t=>this.Rt(t)],["update-position",t=>this.xt(t)],["update-state",t=>this.Tt(t)],["focus",t=>this.It(t)],["set-css-style",t=>this.At(t)],["set-attribute",t=>this.Gt(t)],["remove-attribute",t=>this.Et(t)]]),this.Dt("get-element",t=>t)}Ft(t){this.Pt=!!t}Dt(t,e){this.R(t,t=>{const s=t.elementId,i=this.Wt(s);return e(i,t)})}Lt(t){for(const[s,i]of t)this.Dt(s,i)}Ct(t){const s=t.elementId,i=this.Ut(s,t),e=new y(i),n=(this.kt.set(s,e),i.style.boxSizing="border-box",i.style.display="none",e.lt(t.isVisible),this.Ht(i)),h=(n.addEventListener("focus",t=>this.Bt(s)),n.addEventListener("blur",t=>this.Vt(s)),t.htmlIndex);if(e.yt(h),e.bt(t.htmlZIndex),this.Pt){const o=this.A().jt(h),r=(e.vt(o),this.A().Nt(o));r.appendChild(i)}}Ut(t,s){throw new Error("required override")}zt(t){}Mt(t){const s=t.elementId,i=this.Wt(s);this.zt(i),this.Pt&&i.parentElement.removeChild(i),this.kt.delete(s)}$t(t,s,i){(i=i||{}).elementId=s,this.v(t,i)}qt(t,s,i){(i=i||{}).elementId=s,this.P(t,i)}Rt(t){if(this.Pt){const s=this.kt.get(t.elementId),i=s.St();s.dt()?i.style.display=t.isVisible?"":"none":s.lt(t.isVisible)}}xt(t){if(this.Pt){const s=this.kt.get(t.elementId),i=s.St(),e=this.A(),n=(i.style.left=t.left+"px",i.style.top=t.top+"px",i.style.width=t.width+"px",i.style.height=t.height+"px",t.fontSize),h=(null!==n&&(i.style.fontSize=n+"em"),t.htmlIndex),o=(s.yt(h),e.jt(h));if(o!==s.gt()){i.remove();const a=e.Nt(o);a.appendChild(i),s.vt(o),e.Yt()}const r=t.htmlZIndex;r!==s._t()&&(s.bt(r),e.Yt()),s.dt()||(s.wt(),s.ut()&&(i.style.display=""))}}Xt(){if(this.Pt)for(const t of this.kt.values()){const s=this.A().jt(t.ft()),i=t.gt();if(-1!==s&&-1!==i&&s!==i){const e=t.St(),n=(e.remove(),this.A().Nt(s));n.appendChild(e),t.vt(s)}}}Jt(){return this.Pt?[...this.kt.values()]:null}Tt(t){const s=this.Wt(t.elementId);this.Kt(s,t)}Kt(t,s){throw new Error("required override")}Ht(t){return t}Bt(t){this.$t("elem-focused",t)}Vt(t){this.$t("elem-blurred",t)}It(t){const s=this.Ht(this.Wt(t.elementId));t.focus?s.focus():s.blur()}At(t){const s=this.Wt(t.elementId),i=t.prop,e=t.val;i.startsWith("--")?s.style.setProperty(i,e):s.style[i]=e}Gt(t){const s=this.Wt(t.elementId);s.setAttribute(t.name,t.val)}Et(t){const s=this.Wt(t.elementId);s.removeAttribute(t.name)}Wt(t){const s=this.kt.get(t);if(s)return s.St();throw new Error("no element with id "+t)}}}{const b0=/(iphone|ipod|ipad|macos|macintosh|mac os x)/i.test(navigator.userAgent),c0=/android/i.test(navigator.userAgent),d0=/safari/i.test(navigator.userAgent)&&!/(chrome|chromium|edg\/|OPR\/|nwjs)/i.test(navigator.userAgent);let n=0;function AddScript(i){const e=document.createElement("script");return e.async=!1,e.type="module",i.Zt?new Promise(t=>{const s="c3_resolve_"+n;++n,self[s]=t,e.textContent=i.str+`

self["${s}"]();`,document.head.appendChild(e)}):new Promise((t,s)=>{e.onload=t,e.onerror=s,e.src=i,document.head.appendChild(e)})}async function CheckSupportsWorkerMode(){if(!navigator.userActivation||"undefined"==typeof OffscreenCanvas)return!1;try{let t=!1;const s=new Blob([`
	self.addEventListener("message", () =>
	{
		try {
			const offscreenCanvas = new OffscreenCanvas(32, 32);
			const gl = offscreenCanvas.getContext("webgl");
			self.postMessage(!!gl);
		}
		catch (err)
		{
			console.warn("Feature detection worker error:", err);
			self.postMessage(false);
		}
	});`],{type:"text/javascript"}),i=new Worker(URL.createObjectURL(s),{get type(){t=!0}}),e=await new Promise(s=>{i.addEventListener("message",t=>{i.terminate(),s(t.data)}),i.postMessage("")});return t&&e}catch(t){return console.warn("Error feature detecting worker mode: ",t),!1}}let t=new Audio;const g0={"audio/webm; codecs=opus":!!t.canPlayType("audio/webm; codecs=opus"),"audio/ogg; codecs=opus":!!t.canPlayType("audio/ogg; codecs=opus"),"audio/webm; codecs=vorbis":!!t.canPlayType("audio/webm; codecs=vorbis"),"audio/ogg; codecs=vorbis":!!t.canPlayType("audio/ogg; codecs=vorbis"),"audio/mp4":!!t.canPlayType("audio/mp4"),"audio/mpeg":!!t.canPlayType("audio/mpeg")};async function BlobToString(t){const s=await BlobToArrayBuffer(t),i=new TextDecoder("utf-8");return i.decode(s)}function BlobToArrayBuffer(e){return new Promise((s,i)=>{const t=new FileReader;t.onload=t=>s(t.target.result),t.onerror=t=>i(t),t.readAsArrayBuffer(e)})}t=null;const h0=[];let e=0;const j0=8,k0=(window.RealFile=window.File,[]),l0=new Map,m0=new Map;let r=0;const o0=[],p0=(self.runOnStartup=function(t){if("function"!=typeof t)throw new Error("runOnStartup called without a function");o0.push(t)},new Set(["cordova","playable-ad-single-file","playable-ad-zip","instant-games"]));function IsWebViewExportType(t){return p0.has(t)}let s=!1;window.Qt=class P0{constructor(t){if(this.ts=t.ss,this.es=null,this.ns="",this.hs=t.scriptFolder,this.os=null,this.rs=null,this.cs=[],this.ls=null,this.us=!0,this.ds=[],this.ws=[],this.fs=!1,this.ps=()=>this.ys(),this.gs=!1,this.vs=0,this.bs=null,this._s=-1,this.Ss=()=>this.Os(),this.ks=new Set,this.Ps=null,this.Cs=[],this.Ms=t.exportType,this.Rs="file"===location.protocol.substr(0,4),this.xs=[],"playable-ad-single-file"!==this.Ms&&"playable-ad-zip"!==this.Ms&&"instant-games"!==this.Ms||(this.ts=!1),d0&&(this.ts=!1),"cordova"===this.Ms&&this.ts&&c0){const s=/Chrome\/(\d+)/i.exec(navigator.userAgent);s&&90<=parseInt(s[1],10)||(this.ts=!1)}this.Ts()?self.chrome.webview.addEventListener("message",t=>this.Is(t.data,t.additionalObjects)):"macos-wkwebview"===this.Ms?self.C3WrapperOnMessage=t=>this.Is(t):"linux-cef"===this.Ms&&self.c3_linux_cef_set_message_callback(t=>this.Is(JSON.parse(t))),this.As=null,this.Gs=null,"html5"!==this.Ms||window.isSecureContext||console.warn("[Construct] Warning: the browser indicates this is not a secure context. Some features may be unavailable. Use secure (HTTPS) hosting to ensure all features are available."),this.T("canvas","update-size",t=>this.Es(t)),this.T("canvas","set-html-layer-count",t=>this._OnSetHTMLLayerCount(t)),this.T("canvas","cleanup-html-layers",()=>this.Ds()),this.T("canvas","update-html-layer-dom-state",t=>this.Fs(t.layersDomState)),this.T("runtime","cordova-fetch-local-file",t=>this.Ws(t)),this.T("runtime","create-job-worker",t=>this.Ls(t)),this.T("runtime","send-wrapper-extension-message",t=>this.Us(t)),"cordova"===this.Ms?document.addEventListener("deviceready",()=>this.Hs(t)):this.Hs(t),this.Bs=0}it(){this.Vs(),this.es&&(this.es.onmessage=null,this.es=null),this.os&&(this.os.terminate(),this.os=null),this.rs&&(this.rs.it(),this.rs=null);for(const{canvas:t,js:s}of this.ds)t.remove(),s.remove();this.ds.length=0}Ns(){return this.ds[0].canvas}jt(t){return Math.min(t,this.ds.length-1)}Nt(t){if(t<0||t>=this.ds.length)throw new RangeError("invalid canvas layer");return this.ds[t].js}["_GetHTMLWrapElement"](t){return this.Nt(t)}zs(){return this.ns}C(){return this.ts}$s(){return this.Ms}qs(){return this.Rs}Ys(){return this.hs}Xs(){return b0&&"cordova"===this.Ms}Js(){const t=navigator.userAgent;return b0&&IsWebViewExportType(this.Ms)||navigator.standalone||/crios\/|fxios\/|edgios\//i.test(t)}Ks(){return c0}Zs(){return c0&&IsWebViewExportType(this.Ms)}Qs(){return"windows-webview2"===this.Ms||!!("preview"===this.Ms&&window.chrome&&window.chrome.webview&&window.chrome.webview.postMessage)}Ts(){return this.Qs()||"xbox-uwp-webview2"===this.Ms}ti(){this.Zs()&&this.Bs++}si(){return this.ii().next().value}*ii(){if(!this.Zs())return!0;yield 0===this.Bs,0<this.Bs&&this.Bs--}async Hs(t){if(this.ts){const i=await CheckSupportsWorkerMode();i||(this.ts=!1)}if("macos-wkwebview"===this.Ms)this.ei({type:"ready"});else if(this.Ts()||"linux-cef"===this.Ms){this.ni();const e=await this.hi();this.Cs=e.registeredComponentIds}if("playable-ad-single-file"===this.Ms&&(this.As=self.c3_base64files,this.Gs={},await this.oi()),"nwjs"===this.Ms&&self.nw){const n=self.nw.Window.get();if(n.on("close",()=>self.nw.App.quit()),self.nw.App.manifest["c3-steam-mode"]){let t=0;this.F(()=>{t++,document.documentElement.style.opacity=t%2==0?"1":"0.999"})}}if(t.runtimeBaseUrl)this.ns=t.runtimeBaseUrl;else{const h=location.origin,o=(this.ns=("null"===h?"file:///":h)+location.pathname,this.ns.lastIndexOf("/"));-1!==o&&(this.ns=this.ns.substr(0,o+1))}const s=new MessageChannel;if(this.es=s.port1,this.es.onmessage=t=>this._OnMessageFromRuntime(t.data),window.c3_addPortMessageHandler&&window.c3_addPortMessageHandler(t=>this.ri(t)),this.bs=new self.ai(this),await this.bs.ci(),"object"==typeof window.StatusBar&&window.StatusBar.hide(),"object"==typeof window.AndroidFullScreen)try{await new Promise((t,s)=>{window.AndroidFullScreen.immersiveMode(t,s)})}catch(t){console.error("Failed to enter Android immersive mode: ",t)}this.ts?await this.li(t,s.port2):await this.di(t,s.port2)}wi(t){return{runtimeBaseUrl:this.ns,previewUrl:location.href,windowInnerWidth:this.fi(),windowInnerHeight:this.pi(),cssDisplayMode:this.mi(),devicePixelRatio:window.devicePixelRatio,isFullscreen:P0.yi(),swClientId:window.cr_swClientId||"",exportType:t.exportType,isNWjs:"undefined"!=typeof nw,fileMap:globalThis.c3_swFileMap??new Map(Object.entries(this.As??{})),scriptFolder:this.hs,isDebug:new URLSearchParams(self.location.search).has("debug"),ife:!!self.ife,jobScheduler:this.bs.gi(),supportedAudioFormats:g0,isFileProtocol:this.Rs,isiOSCordova:this.Xs(),isiOSWebView:this.Js(),isWindowsWebView2:this.Qs(),isAnyWebView2Wrapper:this.Ts(),wrapperComponentIds:this.Cs,isFBInstantAvailable:void 0!==self.FBInstant}}async li(t,s){const n=t.vi,i=("preview"===this.Ms?(this.os=new Worker("previewworker.js",{type:"module",name:"Runtime"}),await new Promise((s,i)=>{const e=t=>{this.os.removeEventListener("message",e),(t.data&&"ok"===t.data.type?s:i)()};this.os.addEventListener("message",e),this.os.postMessage({type:"construct-worker-init",import:new URL(n,this.ns).toString()})})):this.os=await this.bi(n,{type:"module",name:"Runtime"}),document.createElement("canvas")),e=(i.style.display="none",i.transferControlToOffscreen()),h=(document.body.appendChild(i),document.createElement("div"));h.className="c3htmlwrap",h.setAttribute("interactive",""),document.body.appendChild(h),this.ds.push({canvas:i,js:h,_i:{isVisible:!0,opacity:1,isInteractive:!0}}),window.c3canvas=i,self.C3_InsertHTMLPlaceholders&&self.C3_InsertHTMLPlaceholders(),this.os.postMessage(Object.assign(this.wi(t),{type:"init-runtime",isInWorker:!0,messagePort:s,canvas:e,runtimeScriptList:t.runtimeScriptList,projectMainScriptPath:t.projectMainScriptPath,scriptsInEventsPath:t.scriptsInEventsPath}),[s,e,...this.bs.Si()]),this.cs=k0.map(t=>new t(this)),this.Oi(),this.ls.ki(i),this.ls.Pi(h),this.ls.Ci(),self.c3_callFunction=(t,s)=>this.ls.Mi(t,s),"preview"===this.Ms&&(self.goToLastErrorScript=()=>this._("runtime","go-to-last-error-script"))}async di(t,s){const i=document.createElement("canvas"),e=(i.style.display="none",document.body.appendChild(i),document.createElement("div")),n=(e.className="c3htmlwrap",e.setAttribute("interactive",""),document.body.appendChild(e),this.ds.push({canvas:i,js:e,_i:{isVisible:!0,opacity:1,isInteractive:!0}}),window.c3canvas=i,self.C3_InsertHTMLPlaceholders&&self.C3_InsertHTMLPlaceholders(),this.cs=k0.map(t=>new t(this)),this.Oi(),this.ls.ki(i),this.ls.Pi(e),await Promise.all(t.runtimeScriptList.map(t=>this.Ri(t)))),h=(await Promise.all(n.map(t=>AddScript(t))),t.projectMainScriptPath),o=t.scriptsInEventsPath;if(h)try{if(await AddScript(h),"preview"===this.Ms&&!globalThis.C3_ProjectMainScriptOK)throw new Error("main script did not run to completion")}catch(t){this.xi(),console.error("Error loading project main script: ",t),alert(`Failed to load the project main script (${h}). Check all your JavaScript code has valid syntax, all imports are written correctly, and that an exception was not thrown running the script. Press F12 and check the console for error details.`)}if(o)try{if(await AddScript(o),"preview"===this.Ms&&!globalThis.C3.ScriptsInEvents)throw new Error("scripts in events did not run to completion")}catch(t){this.xi(),console.error("Error loading scripts in events: ",t),alert("Failed to load scripts in events. Check all your JavaScript code has valid syntax, all imports are written correctly, and that an exception was not thrown running the 'Imports for events' script. Press F12 and check the console for error details.")}const r=Object.assign(this.wi(t),{isInWorker:!1,messagePort:s,canvas:i,runOnStartupFunctions:o0});this.ls.Ci(),this.Ti(),this.rs=self.C3_CreateRuntime(r),await self.C3_InitRuntime(this.rs,r)}async bi(t,s){if(t.startsWith("blob:"))return new Worker(t,s);if("cordova"===this.Ms&&this.Rs){const n=await this.Ii(t),h=new Blob([n],{type:"application/javascript"});return new Worker(URL.createObjectURL(h),s)}if("playable-ad-single-file"===this.Ms){const o=this.As[t];if(o)return new Worker(URL.createObjectURL(o),s);throw new Error("missing script: "+t)}const i=new URL(t,location.href),e=location.origin!==i.origin;if(e){const r=await fetch(i);if(!r.ok)throw new Error("failed to fetch worker script");const a=await r.blob();return new Worker(URL.createObjectURL(a),s)}return new Worker(i,s)}fi(){return Math.max(window.innerWidth,1)}pi(){return Math.max(window.innerHeight,1)}mi(){if(this.Ts())return"standalone";const t=this.$s(),s=new Set(["cordova","nwjs","macos-wkwebview","linux-cef"]);return s.has(t)?"standalone":window.matchMedia("(display-mode: fullscreen)").matches?"fullscreen":window.matchMedia("(display-mode: standalone)").matches?"standalone":window.matchMedia("(display-mode: minimal-ui)").matches?"minimal-ui":navigator.standalone?"standalone":"browser"}Ti(){this.xi()}xi(){const t=window.cr_previewLoadingElem;t&&(t.parentElement.removeChild(t),window.cr_previewLoadingElem=null)}async Ls(t){const s=await this.bs.Ai();return{outputPort:s,transferables:[s]}}Es(t){if(!this.Gi()){const s=t.styleWidth+"px",i=t.styleHeight+"px",e=t.marginLeft+"px",n=t.marginTop+"px";for(const{canvas:h,js:o}of this.ds)h.style.width=s,h.style.height=i,h.style.marginLeft=e,h.style.marginTop=n,o.style.width=s,o.style.height=i,o.style.marginLeft=e,o.style.marginTop=n,this.us&&(h.style.display="",o.style.display="");document.documentElement.style.setProperty("--construct-scale",t.displayScale),this.us=!1}}["_OnSetHTMLLayerCount"](t){const i=t.count,s=t.layersDomState,e=t.immediate,n=t.styleWidth+"px",h=t.styleHeight+"px",o=t.marginLeft+"px",r=t.marginTop+"px",a=[],c=[];if(i<this.ds.length)for(;this.ds.length>i;){const{canvas:l,js:u}=this.ds.pop();u.remove(),this.ts&&!e?this.ws.push(l):l.remove()}else if(i>this.ds.length)for(let t=0,s=i-this.ds.length;t<s;++t){const d=document.createElement("canvas");if(d.classList.add("c3overlay"),this.ts){const f=d.transferControlToOffscreen();a.push(f),c.push(f)}else a.push(d);document.body.appendChild(d);const w=document.createElement("div");w.classList.add("c3htmlwrap","c3overlay"),w.setAttribute("interactive",""),document.body.appendChild(w),d.style.width=n,d.style.height=h,d.style.marginLeft=o,d.style.marginTop=r,w.style.width=n,w.style.height=h,w.style.marginLeft=o,w.style.marginTop=r,this.ls.ki(d),this.ls.Pi(w),this.ds.push({canvas:d,js:w,_i:{isVisible:!0,opacity:1,isInteractive:!0}})}this.Fs(s);for(const p of this.cs)p instanceof window.Ot&&p.Xt();return this.Yt(),{addedCanvases:a,transferables:c}}Fs(i){for(let t=0,s=Math.min(this.ds.length,i.length);t<s;++t){const{js:e,_i:n}=this.ds[t],h=i[t],o=h.isVisible,r=h.opacity,a=h.isInteractive;o!==n.isVisible&&(e.style.display=o?"":"none",n.isVisible=o),r!==n.opacity&&(e.style.opacity=1===r?"":String(r),n.opacity=r),a!==n.isInteractive&&(e.style.pointerEvents=a?"":"none",a?e.setAttribute("interactive",""):e.removeAttribute("interactive"),n.isInteractive=a)}}Ds(){for(const t of this.ws)t.remove();this.ws.length=0}Yt(){this.fs||(this.fs=!0,this.F(this.ps))}ys(){this.L(this.ps),this.fs=!1;let t=[];for(const h of this.cs)if(h instanceof window.Ot){const o=h.Jt();o&&t.push(...o)}t.sort((t,s)=>{const i=t.gt(),e=s.gt();if(i!==e)return i-e;const n=t._t(),h=s._t();return n-h});let s=0,i=0,e=0,n=t.length;for(;e<n;++e){const r=t[e];r.gt()!==s&&(this.Ei(s,t.slice(i,e)),s=r.gt(),i=e)}i<e&&this.Ei(s,t.slice(i,e))}Ei(t,s){if(!(s.length<=1||t>=this.ds.length)){const e=s.map(t=>t.St()),i=new Set(e),n=this.Nt(t),h=Array.from(n.children).filter(t=>i.has(t));for(let t=0,s=0,i=e.length;t<i;++t){const o=e[t],r=h[s];o===r?++s:n.insertBefore(o,r)}}}M(){if(this.ts)throw new Error("not available in worker mode");return this.rs}_(t,s,i,e,n){this.es.postMessage({type:"event",component:t,handler:s,dispatchOpts:e||null,data:i,responseId:null},n)}O(t,s,i,e,n){const h=r++,o=new Promise((t,s)=>{m0.set(h,{resolve:t,reject:s})});return this.es.postMessage({type:"event",component:t,handler:s,dispatchOpts:e||null,data:i,responseId:h},n),o}["_OnMessageFromRuntime"](t){const s=t.type;if("event"===s)return this.Di(t);if("result"===s)this.Fi(t);else if("runtime-ready"===s)this.Wi();else if("alert-error"===s)this.xi(),alert(t.message);else{if("creating-runtime"!==s)throw new Error(`unknown message '${s}'`);this.Ti()}}Di(s){const i=s.component,e=s.handler,n=s.data,h=s.responseId,t=l0.get(i);if(t){const o=t.get(e);if(o){let t=null;try{t=o(n)}catch(s){return console.error(`Exception in '${i}' handler '${e}':`,s),void(null!==h&&this.Li(h,!1,""+s))}if(null===h)return t;t&&t.then?t.then(t=>this.Li(h,!0,t)).catch(t=>{console.error(`Rejection from '${i}' handler '${e}':`,t),this.Li(h,!1,""+t)}):this.Li(h,!0,t)}else console.warn(`[DOM] No handler '${e}' for component '${i}'`)}else console.warn(`[DOM] No event handlers for component '${i}'`)}Li(t,s,i){let e;i&&i.transferables&&(e=i.transferables),this.es.postMessage({type:"result",responseId:t,isOk:s,result:i},e)}Fi(t){const s=t.responseId,i=t.isOk,e=t.result,n=m0.get(s);i?n.resolve(e):n.reject(e),m0.delete(s)}T(t,s,i){let e=l0.get(t);if(e||(e=new Map,l0.set(t,e)),e.has(s))throw new Error(`[DOM] Component '${t}' already has handler '${s}'`);e.set(s,i)}static Ui(t){if(k0.includes(t))throw new Error("DOM handler already added");k0.push(t)}Oi(){for(const t of this.cs)if("runtime"===t.G())return void(this.ls=t);throw new Error("cannot find runtime DOM handler")}ri(t){this._("debugger","message",t)}Wi(){for(const t of this.cs)t.g()}static yi(){return!!(document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||s)}static Hi(t){s=!!t}async Bi(){return this.O("runtime","get-remote-preview-status-info")}F(t){this.ks.add(t),this.Vi()}L(t){this.ks.delete(t),0===this.ks.size&&this.Vs()}Vi(){-1===this._s&&0<this.ks.size&&(this._s=requestAnimationFrame(this.Ss))}Vs(){-1!==this._s&&(cancelAnimationFrame(this._s),this._s=-1)}Os(){this._s=-1;for(const t of this.ks)t();this.Vi()}ji(t){this.ls.ji(t)}Ni(t){this.ls.Ni(t)}zi(){this.ls.zi()}$i(t){this.ls.$i(t)}Yi(t){return!!g0[t]}async Xi(t){const s=await this.O("runtime","opus-decode",{arrayBuffer:t},null,[t]);return new Float32Array(s)}Ji(t){this.gs=!0,this.vs=t}Gi(){return this.gs}Ki(){return this.vs}Zi(t){return/^(?:[a-z\-]+:)?\/\//.test(t)||"data:"===t.substr(0,5)||"blob:"===t.substr(0,5)}Qi(t){return!this.Zi(t)}async Ri(s){if("cordova"===this.Ms&&(s.startsWith("file:")||this.Rs&&this.Qi(s))){let t=s;t.startsWith(this.ns)&&(t=t.substr(this.ns.length));const i=await this.Ii(t),e=new Blob([i],{type:"application/javascript"});return URL.createObjectURL(e)}if("playable-ad-single-file"!==this.Ms)return s;if(this.Gs.hasOwnProperty(s))return{Zt:!0,str:this.Gs[s]};if(this.As.hasOwnProperty(s))return URL.createObjectURL(this.As[s]);throw new Error("missing script: "+s)}async Ws(t){const s=t.filename;switch(t.as){case"text":return this.te(s);case"buffer":return this.Ii(s);default:throw new Error("unsupported type")}}se(t){const e=window.cordova.file.applicationDirectory+"www/"+t;return new Promise((s,i)=>{window.resolveLocalFileSystemURL(e,t=>{t.file(s,i)},i)})}async te(t){const s=await this.se(t);return BlobToString(s)}ie(){if(h0.length&&!(e>=j0)){e++;const t=h0.shift();this.ee(t.filename,t.ne,t.he)}}Ii(t){return new Promise((s,i)=>{h0.push({filename:t,ne:t=>{e--,this.ie(),s(t)},he:t=>{e--,this.ie(),i(t)}}),this.ie()})}async ee(t,s,i){try{const e=await this.se(t),n=await BlobToArrayBuffer(e);s(n)}catch(t){i(t)}}["_PlayableAdFetchBlob"](t){if(this.As.hasOwnProperty(t))return this.As[t];throw new Error("missing file: "+t)}oe(){const t=window.cordova&&window.cordova.plugins&&window.cordova.plugins.permissions;if("object"!=typeof t)throw new Error("Permission API is not loaded");return t}re(t,s){const i=t[s];if("string"!=typeof i)throw new Error("Invalid permission name");return i}ae(i){const e=this.oe();return new Promise((s,t)=>e.checkPermission(this.re(e,i),t=>s(!!t.hasPermission),t))}ce(i){const e=this.oe();return new Promise((s,t)=>e.requestPermission(this.re(e,i),t=>s(!!t.hasPermission),t))}async le(t){if("cordova"===this.$s()&&!this.Xs())for(const s of t){const i=await this.ae(s);if(!i){const e=await this.ce(s);if(!1===e)return!1}}return!0}async ue(...t){if(!1===await this.le(t))throw new Error("Permission not granted")}Is(t,s){if("entered-fullscreen"===t)P0.Hi(!0),this.ls.de();else if("exited-fullscreen"===t)P0.Hi(!1),this.ls.de();else if("object"==typeof t){const i=t.type;"directory-handles"===i?this.xs=s:"wrapper-init-response"===i?(this.Ps(t),this.Ps=null):"extension-message"===i?this._("runtime","wrapper-extension-message",t):console.warn("Unknown wrapper message: ",t)}else console.warn("Unknown wrapper message: ",t)}Us(t){this.ei({type:"extension-message",componentId:t.componentId,messageId:t.messageId,params:t.params||[],asyncId:t.asyncId})}ei(t){this.Ts()?window.chrome.webview.postMessage(JSON.stringify(t)):"macos-wkwebview"===this.Ms?window.webkit.messageHandlers.C3Wrapper.postMessage(JSON.stringify(t)):"linux-cef"===this.Ms&&window.c3_linux_cef_sendmessage(JSON.stringify(t))}ni(){window.moveTo=(t,s)=>{this.ei({type:"set-window-position",windowX:Math.ceil(t),windowY:Math.ceil(s)})},window.resizeTo=(t,s)=>{this.ei({type:"set-window-size",windowWidth:Math.ceil(t),windowHeight:Math.ceil(s)})}}hi(){return new Promise(t=>{this.Ps=t,this.ei({type:"wrapper-init"})})}we(){return this.xs}async oi(){const t=[];for(const[s,i]of Object.entries(this.As))t.push(this.fe(s,i));await Promise.all(t)}async fe(s,i){if("object"==typeof i)this.As[s]=new Blob([i.str],{type:i.type}),this.Gs[s]=i.str;else{let t=await this.pe(i);t=t||this.me(i),this.As[s]=t}}async pe(t){try{const s=await fetch(t);return await s.blob()}catch(t){return console.warn("Failed to fetch a data: URI. Falling back to a slower workaround. This is probably because the Content Security Policy unnecessarily blocked it. Allow data: URIs in your CSP to avoid this.",t),null}}me(t){const s=this.ye(t);return this.ge(s.data,s.ve)}ye(t){const s=t.indexOf(",");if(s<0)throw new URIError("expected comma in data: uri");const i=t.substring(5,s),e=t.substring(s+1),n=i.split(";"),h=n[0]||"",o=n[1],r=n[2];return{ve:h,data:("base64"===o||"base64"===r?atob:decodeURIComponent)(e)}}ge(t,s){let i=t.length,e=i>>2,n=new Uint8Array(i),h=new Uint32Array(n.buffer,0,e),o,r;for(o=0,r=0;o<e;++o)h[o]=t.charCodeAt(r++)|t.charCodeAt(r++)<<8|t.charCodeAt(r++)<<16|t.charCodeAt(r++)<<24;let a=3&i;for(;a--;)n[r]=t.charCodeAt(r),++r;return new Blob([n],{type:s})}}}{const Od=self.Qt;function IsCompatibilityMouseEvent(t){return t.sourceCapabilities&&t.sourceCapabilities.firesTouchEvents||t.originalEvent&&t.originalEvent.sourceCapabilities&&t.originalEvent.sourceCapabilities.firesTouchEvents}const Pd=new Map([["OSLeft","MetaLeft"],["OSRight","MetaRight"]]),Qd={dispatchRuntimeEvent:!0,dispatchUserScriptEvent:!0},Rd={dispatchUserScriptEvent:!0},Sd={dispatchRuntimeEvent:!0};function AddStyleSheet(e){return new Promise((t,s)=>{const i=document.createElement("link");i.onload=()=>t(i),i.onerror=t=>s(t),i.rel="stylesheet",i.href=e,document.head.appendChild(i)})}function FetchImage(e){return new Promise((t,s)=>{const i=new Image;i.onload=()=>t(i),i.onerror=t=>s(t),i.src=e})}async function BlobToImage(t){const s=URL.createObjectURL(t);try{return await FetchImage(s)}finally{URL.revokeObjectURL(s)}}function BlobToString(e){return new Promise((s,i)=>{let t=new FileReader;t.onload=t=>s(t.target.result),t.onerror=t=>i(t),t.readAsText(e)})}function IsInContentEditable(t){do{if(t.parentNode&&t.hasAttribute("contenteditable"))return!0}while(t=t.parentNode);return!1}const Td=new Set(["input","textarea","datalist","select"]);function IsKeyboardInputElement(t){return Td.has(t.tagName.toLowerCase())||IsInContentEditable(t)}const Ud=new Set(["canvas","body","html"]);function PreventDefaultOnCanvasOrDoc(t){if(t.target.tagName){const s=t.target.tagName.toLowerCase();Ud.has(s)&&t.preventDefault()}}function PreventDefaultOnHTMLWrap(t){t.target.tagName&&t.target.classList.contains("c3htmlwrap")&&t.preventDefault()}function BlockWheelZoom(t){(t.metaKey||t.ctrlKey)&&t.preventDefault()}self.C3_GetSvgImageSize=async function(t){const s=await BlobToImage(t);if(0<s.width&&0<s.height)return[s.width,s.height];{s.style.position="absolute",s.style.left="0px",s.style.top="0px",s.style.visibility="hidden",document.body.appendChild(s);const i=s.getBoundingClientRect();return document.body.removeChild(s),[i.width,i.height]}};let t=!(self.C3_RasterSvgImageBlob=async function(t,s,i,e,n){const h=await BlobToImage(t),o=document.createElement("canvas"),r=(o.width=e,o.height=n,o.getContext("2d"));return r.drawImage(h,0,0,s,i),o});function ParentHasFocus(){try{return window.parent&&window.parent.document.hasFocus()}catch(t){return!1}}document.addEventListener("pause",()=>t=!0),document.addEventListener("resume",()=>t=!1);const Wd="runtime",Xd=class extends self.i{constructor(t){super(t,Wd),this.be=!1,this._e=-1,this.Se="any",this.Oe=!1,this.ke=!1,this.Pe=!1,this.Ce=document.createElement("div"),this.Ce.className="c3-screen-reader-text",this.Ce.setAttribute("aria-live","polite"),document.body.appendChild(this.Ce),this.Me=null,this.Re=!1,this.xe="",this.Te=-1,this.Ie=!1,this.Ae=t.fi(),this.Ge=t.pi(),this.Ee=0,this.De=0,t.T("runtime","invoke-download",t=>this.Fe(t)),t.T("runtime","load-webfonts",t=>this.We(t)),t.T("runtime","raster-svg-image",t=>this.Le(t)),t.T("runtime","get-svg-image-size",t=>this.Ue(t)),t.T("runtime","set-target-orientation",t=>this.He(t)),t.T("runtime","register-sw",()=>this.Be()),t.T("runtime","post-to-debugger",t=>this.Ve(t)),t.T("runtime","go-to-script",t=>this.Ve(t)),t.T("runtime","before-start-ticking",()=>this.je()),t.T("runtime","debug-highlight",t=>this.Ne(t)),t.T("runtime","enable-device-orientation",()=>this.ze()),t.T("runtime","enable-device-motion",()=>this.$e()),t.T("runtime","add-stylesheet",t=>this.qe(t)),t.T("runtime","script-create-worker",t=>this.Ye(t)),t.T("runtime","alert",t=>this.Xe(t)),t.T("runtime","screen-reader-text",t=>this.Je(t)),t.T("runtime","hide-cordova-splash",()=>this.Ke()),t.T("runtime","set-exporting-to-video",t=>this.Ze(t)),t.T("runtime","export-to-video-progress",t=>this.Qe(t)),t.T("runtime","exported-to-video",t=>this.tn(t)),t.T("runtime","exported-to-image-sequence",t=>this.sn(t));const e=new Set(["input","textarea","datalist"]);if(window.addEventListener("contextmenu",t=>{const s=t.target,i=s.tagName.toLowerCase();e.has(i)||IsInContentEditable(s)||t.preventDefault()}),window.addEventListener("selectstart",PreventDefaultOnCanvasOrDoc),window.addEventListener("gesturehold",PreventDefaultOnCanvasOrDoc),window.addEventListener("touchstart",PreventDefaultOnCanvasOrDoc,{passive:!1}),window.addEventListener("pointerdown",PreventDefaultOnCanvasOrDoc,{passive:!1}),this.en=0,window.addEventListener("mousedown",t=>{1===t.button&&t.preventDefault()}),window.addEventListener("mousewheel",BlockWheelZoom,{passive:!1}),window.addEventListener("wheel",BlockWheelZoom,{passive:!1}),window.addEventListener("resize",()=>this.nn()),window.addEventListener("fullscreenchange",()=>this.de()),window.addEventListener("webkitfullscreenchange",()=>this.de()),window.addEventListener("mozfullscreenchange",()=>this.de()),window.addEventListener("fullscreenerror",t=>this.hn(t)),window.addEventListener("webkitfullscreenerror",t=>this.hn(t)),window.addEventListener("mozfullscreenerror",t=>this.hn(t)),t.Js()){let s=1/0;window.visualViewport.addEventListener("resize",()=>{const t=window.visualViewport.height;t>s&&(document.scrollingElement.scrollTop=0,document.scrollingElement.scrollLeft=0),s=t}),document.documentElement.setAttribute("ioswebview","")}this.rn=new Set,this.an=new WeakSet,this.cn=!1}ki(t){t.addEventListener("selectstart",PreventDefaultOnCanvasOrDoc),t.addEventListener("gesturehold",PreventDefaultOnCanvasOrDoc),t.addEventListener("pointerdown",PreventDefaultOnCanvasOrDoc)}Pi(t){t.addEventListener("selectstart",PreventDefaultOnHTMLWrap),t.addEventListener("gesturehold",PreventDefaultOnHTMLWrap),t.addEventListener("touchstart",PreventDefaultOnHTMLWrap)}je(){return self.setTimeout(()=>{this.Ie=!0},1e3),"cordova"===this.h.$s()?(document.addEventListener("pause",()=>this.ln(!0)),document.addEventListener("resume",()=>this.ln(!1))):document.addEventListener("visibilitychange",()=>this.ln("hidden"===document.visibilityState)),this.Pe=!("hidden"!==document.visibilityState&&!t),{isSuspended:this.Pe}}g(){window.addEventListener("focus",()=>this.un("window-focus")),window.addEventListener("blur",()=>{this.un("window-blur",{parentHasFocus:ParentHasFocus()}),this.en=0}),window.addEventListener("focusin",t=>{IsKeyboardInputElement(t.target)&&this.un("keyboard-blur")}),window.addEventListener("keydown",t=>this.dn("keydown",t)),window.addEventListener("keyup",t=>this.dn("keyup",t)),window.addEventListener("mousedown",t=>this.wn("mousedown",t,Rd)),window.addEventListener("mousemove",t=>this.wn("mousemove",t,Rd)),window.addEventListener("mouseup",t=>this.wn("mouseup",t,Rd)),window.addEventListener("dblclick",t=>this.wn("dblclick",t,Qd)),window.addEventListener("wheel",t=>this.fn("wheel",t,Qd)),window.addEventListener("pointerdown",t=>{this.pn(t),this.mn("pointerdown",t)}),this.h.C()&&void 0!==window.onpointerrawupdate&&self===self.top?window.addEventListener("pointerrawupdate",t=>this.yn(t)):window.addEventListener("pointermove",t=>this.mn("pointermove",t)),window.addEventListener("pointerup",t=>this.mn("pointerup",t)),window.addEventListener("pointercancel",t=>this.mn("pointercancel",t));const t=()=>this.zi();window.addEventListener("pointerup",t,!0),window.addEventListener("touchend",t,!0),window.addEventListener("click",t,!0),window.addEventListener("keydown",t,!0),window.addEventListener("gamepadconnected",t,!0),this.h.Ks()&&!this.h.Zs()&&navigator.virtualKeyboard&&(navigator.virtualKeyboard.overlaysContent=!0,navigator.virtualKeyboard.addEventListener("geometrychange",()=>{this.gn(this.pi(),navigator.virtualKeyboard.boundingRect.height)})),this.h.Js()&&(document.scrollingElement.scrollTop=0,document.scrollingElement.scrollLeft=0)}gn(s,i){if(document.body.style.position="",document.body.style.overflow="",document.body.style.transform="",(this.De=0)<i){const e=document.activeElement;if(e){const n=e.getBoundingClientRect(),h=(n.top+n.bottom)/2,o=(s-i)/2;let t=h-o;0<(t=(t=i<t?i:t)<0?0:t)&&(document.body.style.position="absolute",document.body.style.overflow="visible",document.body.style.transform=`translateY(${-t}px)`,this.De=t)}}}un(t,s){this.v(t,s||null,Sd)}fi(){return this.h.fi()}pi(){return this.h.pi()}Ci(){this.be=!0,this.Ae=this.h.fi(),this.Ge=this.h.pi()}nn(){if(!this.Re&&this.be){const t=this.fi(),s=this.pi();if(this.h.Zs()){if(this.Ie){const i=this.h.si();if(i&&this.Ae===t&&s<this.Ge)return this.Ee=this.Ge-s,void this.gn(this.Ge,this.Ee);0<this.Ee&&(this.Ee=0,this.gn(s,this.Ee))}this.Ae=t,this.Ge=s}this.v("window-resize",{innerWidth:t,innerHeight:s,devicePixelRatio:window.devicePixelRatio,isFullscreen:Od.yi(),cssDisplayMode:this.h.mi()}),this.h.Js()&&(-1!==this._e&&clearTimeout(this._e),this.vn(t,s,0))}}bn(t,s,i){-1!==this._e&&clearTimeout(this._e),this._e=setTimeout(()=>this.vn(t,s,i),48)}vn(t,s,i){const e=this.fi(),n=this.pi();this._e=-1,e!=t||n!=s?this.v("window-resize",{innerWidth:e,innerHeight:n,devicePixelRatio:window.devicePixelRatio,isFullscreen:Od.yi(),cssDisplayMode:this.h.mi()}):i<10&&this.bn(e,n,i+1)}He(t){this.Se=t.targetOrientation}_n(){const s=this.Se;if(screen.orientation&&screen.orientation.lock)screen.orientation.lock(s).catch(t=>console.warn("[Construct] Failed to lock orientation: ",t));else try{let t=!1;screen.lockOrientation?t=screen.lockOrientation(s):screen.webkitLockOrientation?t=screen.webkitLockOrientation(s):screen.mozLockOrientation?t=screen.mozLockOrientation(s):screen.msLockOrientation&&(t=screen.msLockOrientation(s)),t||console.warn("[Construct] Failed to lock orientation")}catch(t){console.warn("[Construct] Failed to lock orientation: ",t)}}de(){if(!this.Re){const t=Od.yi();t&&"any"!==this.Se&&this._n(),this.v("fullscreenchange",{isFullscreen:t,innerWidth:this.fi(),innerHeight:this.pi()})}}hn(t){console.warn("[Construct] Fullscreen request failed: ",t),this.v("fullscreenerror",{isFullscreen:Od.yi(),innerWidth:this.fi(),innerHeight:this.pi()})}ln(t){if(this.Pe!==t&&((this.Pe=t)?this.h.Vs():this.h.Vi(),this.v("visibilitychange",{hidden:t}),!t)&&this.h.Js()){const s=()=>{document.scrollingElement.scrollTop=0,document.scrollingElement.scrollLeft=0};setTimeout(s,50),setTimeout(s,100),setTimeout(s,250),setTimeout(s,500)}}dn(t,s){if(void 0!==s.key&&("Backspace"===s.key&&PreventDefaultOnCanvasOrDoc(s),"nwjs"===this.h.$s()&&"u"===s.key&&(s.ctrlKey||s.metaKey)&&s.preventDefault(),!this.Re)){const i=Pd.get(s.code)||s.code;this.P(t,{code:i,key:s.key,which:s.which,repeat:s.repeat,altKey:s.altKey,ctrlKey:s.ctrlKey,metaKey:s.metaKey,shiftKey:s.shiftKey,timeStamp:s.timeStamp},Qd)}}fn(t,s,i){this.Re||this.v(t,{clientX:s.clientX,clientY:s.clientY+this.De,pageX:s.pageX,pageY:s.pageY+this.De,deltaX:s.deltaX,deltaY:s.deltaY,deltaZ:s.deltaZ,deltaMode:s.deltaMode,timeStamp:s.timeStamp},i)}wn(t,s,i){this.Re||IsCompatibilityMouseEvent(s)||this.P(t,{button:s.button,buttons:s.buttons,clientX:s.clientX,clientY:s.clientY+this.De,pageX:s.pageX,pageY:s.pageY+this.De,movementX:s.movementX||0,movementY:s.movementY||0,timeStamp:s.timeStamp},i)}mn(s,i){if(!this.Re){let t=0;"mouse"===i.pointerType&&(t=this.en),this.P(s,{pointerId:i.pointerId,pointerType:i.pointerType,button:i.button,buttons:i.buttons,lastButtons:t,clientX:i.clientX,clientY:i.clientY+this.De,pageX:i.pageX,pageY:i.pageY+this.De,movementX:i.movementX||0,movementY:i.movementY||0,width:i.width||0,height:i.height||0,pressure:i.pressure||0,tangentialPressure:i.tangentialPressure||0,tiltX:i.tiltX||0,tiltY:i.tiltY||0,twist:i.twist||0,timeStamp:i.timeStamp},Qd),"mouse"===i.pointerType&&(this.en=i.buttons)}}yn(t){this.mn("pointermove",t)}Sn(i,e){if(!this.Re)for(let t=0,s=e.changedTouches.length;t<s;++t){const n=e.changedTouches[t];this.P(i,{pointerId:n.identifier,pointerType:"touch",button:0,buttons:0,lastButtons:0,clientX:n.clientX,clientY:n.clientY+this.De,pageX:n.pageX,pageY:n.pageY+this.De,movementX:e.movementX||0,movementY:e.movementY||0,width:2*(n.radiusX||n.webkitRadiusX||0),height:2*(n.radiusY||n.webkitRadiusY||0),pressure:n.force||n.webkitForce||0,tangentialPressure:0,tiltX:0,tiltY:0,twist:n.rotationAngle||0,timeStamp:e.timeStamp},Qd)}}pn(t){window!==window.top&&window.focus(),this.On(t.target)&&document.activeElement&&!this.On(document.activeElement)&&document.activeElement.blur()}On(t){return!t||t===document||t===window||t===document.body||"canvas"===t.tagName.toLowerCase()}ze(){this.Oe||(this.Oe=!0,window.addEventListener("deviceorientation",t=>this.kn(t)),window.addEventListener("deviceorientationabsolute",t=>this.Pn(t)))}$e(){this.ke||(this.ke=!0,window.addEventListener("devicemotion",t=>this.Cn(t)))}kn(t){this.Re||this.v("deviceorientation",{absolute:!!t.absolute,alpha:t.alpha||0,beta:t.beta||0,gamma:t.gamma||0,timeStamp:t.timeStamp,webkitCompassHeading:t.webkitCompassHeading,webkitCompassAccuracy:t.webkitCompassAccuracy},Qd)}Pn(t){this.Re||this.v("deviceorientationabsolute",{absolute:!!t.absolute,alpha:t.alpha||0,beta:t.beta||0,gamma:t.gamma||0,timeStamp:t.timeStamp},Qd)}Cn(e){if(!this.Re){let t=null;const n=e.acceleration;n&&(t={x:n.x||0,y:n.y||0,z:n.z||0});let s=null;const h=e.accelerationIncludingGravity;h&&(s={x:h.x||0,y:h.y||0,z:h.z||0});let i=null;const o=e.rotationRate;o&&(i={alpha:o.alpha||0,beta:o.beta||0,gamma:o.gamma||0}),this.v("devicemotion",{acceleration:t,accelerationIncludingGravity:s,rotationRate:i,interval:e.interval,timeStamp:e.timeStamp},Qd)}}Fe(t){const s=t.url,i=t.filename,e=document.createElement("a"),n=document.body;e.textContent=i,e.href=s,e.download=i,n.appendChild(e),e.click(),n.removeChild(e)}async We(t){const s=t.webfonts;await Promise.all(s.map(async t=>{const s=new FontFace(t.name,`url('${t.url}')`);document.fonts.add(s),await s.load()}))}async Le(t){const s=t.blob,i=t.imageWidth,e=t.imageHeight,n=t.surfaceWidth,h=t.surfaceHeight,o=t.imageBitmapOpts,r=await self.C3_RasterSvgImageBlob(s,i,e,n,h);let a;return{imageBitmap:a=o?await createImageBitmap(r,o):await createImageBitmap(r),transferables:[a]}}async Ue(t){return self.C3_GetSvgImageSize(t.blob)}async qe(t){await AddStyleSheet(t.url)}zi(){const t=[...this.rn];if(this.rn.clear(),!this.cn)for(const s of t){const i=s.play();i&&i.catch(t=>{this.an.has(s)||this.rn.add(s)})}}ji(s){if("function"!=typeof s.play)throw new Error("missing play function");this.an.delete(s);let t;try{t=s.play()}catch(t){return void this.rn.add(s)}t&&t.catch(t=>{this.an.has(s)||this.rn.add(s)})}Ni(t){this.rn.delete(t),this.an.add(t)}$i(t){this.cn=!!t}Ke(){navigator.splashscreen&&navigator.splashscreen.hide&&navigator.splashscreen.hide()}Ne(t){const s=t.show;if(s){this.Me||(this.Me=document.createElement("div"),this.Me.id="inspectOutline",document.body.appendChild(this.Me));const i=this.Me;i.style.display="",i.style.left=t.left-1+"px",i.style.top=t.top-1+"px",i.style.width=t.width+2+"px",i.style.height=t.height+2+"px",i.textContent=t.name}else this.Me&&(this.Me.style.display="none")}Be(){window.C3_RegisterSW&&window.C3_RegisterSW()}Ve(t){window.c3_postToMessagePort&&(t.from="runtime",window.c3_postToMessagePort(t))}Mi(t,s){return this.S("js-invoke-function",{name:t,params:s})}Ye(t){const s=t.url,i=t.opts,e=t.port2,n=new Worker(s,i);n.postMessage({type:"construct-worker-init",port2:e},[e])}Xe(t){alert(t.message)}Je(t){const s=t.type;if("create"===s){const i=document.createElement("p");i.id="c3-sr-"+t.id,i.textContent=t.text,this.Ce.appendChild(i)}else if("update"===s){const e=document.getElementById("c3-sr-"+t.id);e?e.textContent=t.text:console.warn("[Construct] Missing screen reader text with id "+t.id)}else if("release"===s){const n=document.getElementById("c3-sr-"+t.id);n?n.remove():console.warn("[Construct] Missing screen reader text with id "+t.id)}else console.warn(`[Construct] Unknown screen reader text update '${s}'`)}Ze(t){this.Re=!0;const s=document.createElement("h1");s.id="exportToVideoMessage",s.textContent=t.message,document.body.prepend(s),document.body.classList.add("exportingToVideo"),this.A().Ns().style.display="",this.h.Ji(t.duration)}Qe(t){this.xe=t.message,-1===this.Te&&(this.Te=setTimeout(()=>this.Mn(),250))}Mn(){this.Te=-1;const t=document.getElementById("exportToVideoMessage");t&&(t.textContent=this.xe)}tn(t){window.c3_postToMessagePort({type:"exported-video",arrayBuffer:t.arrayBuffer,contentType:t.contentType,time:t.time})}sn(t){window.c3_postToMessagePort({type:"exported-image-sequence",blobArr:t.blobArr,time:t.time,gif:t.gif})}};Od.Ui(Xd)}{const Cf="dispatchworker.js",Df="jobworker.js";self.ai=class{constructor(t){this.Rn=t,this.xn=Math.min(navigator.hardwareConcurrency||2,16),this.Tn=null,this.In=[],this.An=null,this.Gn=null}async ci(){if(this.En)throw new Error("already initialised");this.En=!0;const t=this.Rn.Ys()+Cf,s=(this.Tn=await this.Rn.bi(t,{name:"DispatchWorker"}),new MessageChannel);this.An=s.port1,this.Tn.postMessage({type:"_init","in-port":s.port2},[s.port2]),this.Gn=await this.Ai()}async Ai(){const t=this.In.length,s=this.Rn.Ys()+Df,i=await this.Rn.bi(s,{name:"JobWorker"+t}),e=new MessageChannel,n=new MessageChannel;return this.Tn.postMessage({type:"_addJobWorker",port:e.port1},[e.port1]),i.postMessage({type:"init",number:t,"dispatch-port":e.port2,"output-port":n.port2},[e.port2,n.port2]),this.In.push(i),n.port1}gi(){return{inputPort:this.An,outputPort:this.Gn,maxNumWorkers:this.xn}}Si(){return[this.An,this.Gn]}}}{const Mf="gamepad";let s=!1;const Of=class extends self.i{constructor(t){super(t,Mf),this.Dn=!1,this.V=-1,this.R("ready",()=>this.Fn()),this.R("vibrate-dual-rumble",t=>this.Wn(t)),this.R("vibrate-trigger-rumble",t=>this.Ln(t)),this.R("reset-vibrate",t=>this.Un(t)),this.R("suspend",()=>this.Hn()),this.R("resume",()=>this.Bn()),window.addEventListener("gamepadconnected",t=>this.Vn(t)),window.addEventListener("gamepaddisconnected",t=>this.jn(t)),window.addEventListener("unload",()=>this.Nn())}zn(){try{return Array.from(navigator.getGamepads()).filter(t=>t&&t.connected)}catch(t){return s||(console.warn("[Construct] Failed to access gamepads: ",t),s=!0),[]}}Fn(){this.Dn=!0;for(const t of this.zn())this.$n(t);this.qn()}qn(){-1===this.V&&(this.V=setInterval(()=>this.Yn(),4))}Xn(){-1!==this.V&&(clearInterval(this.V),this.V=-1)}Hn(){this.Xn()}Bn(){this.qn()}Vn(t){this.Dn&&this.$n(t.gamepad)}Jn(t){const s=t.vibrationActuator;return s&&s.playEffect&&Array.isArray(s.effects)?s.effects:[]}Kn(t){return{index:t.index,id:t.id,vibrationEffects:this.Jn(t)}}$n(t){this.v("gamepad-connected",this.Kn(t))}jn(t){if(this.Dn){const s=t.gamepad;this.v("gamepad-disconnected",{index:s.index})}}Yn(){const t=this.zn();if(t.length){const s=t.map(t=>Object.assign(this.Kn(t),{buttons:t.buttons.map(t=>({pressed:t.pressed,value:t.value})),axes:t.axes}));this.v("input-update",s)}}Zn(t){for(const s of this.zn())if(s.index===t)return s;return null}async Wn(t){const s=this.Zn(t.index);if(s){const i=s.vibrationActuator;if(i&&i.playEffect)try{await i.playEffect("dual-rumble",{duration:t.duration,startDelay:0,weakMagnitude:t.weakMag,strongMagnitude:t.strongMag})}catch(t){console.warn("[Gamepad] Failed to vibrate gamepad (dual rumble): ",t)}}}async Ln(t){const s=this.Zn(t.index);if(s){const i=s.vibrationActuator;if(i&&i.playEffect)try{await i.playEffect("trigger-rumble",{duration:t.duration,startDelay:0,weakMagnitude:t.weakMag,strongMagnitude:t.strongMag,leftTrigger:t.leftMag,rightTrigger:t.rightMag})}catch(t){console.warn("[Gamepad] Failed to vibrate gamepad (trigger rumble): ",t)}}}Un(t){const s=this.Zn(t.index);if(s){const i=s.vibrationActuator;i&&i.reset&&i.reset()}}Nn(){for(const t of this.zn()){const s=t.vibrationActuator;s&&s.reset&&s.reset()}}};self.Qt.Ui(Of)}{const u5=180/Math.PI,v5="audio";self.Qn=class extends self.i{constructor(t){super(t,v5),this.th=null,this.sh=null,this.ih=!1,this.eh=!1,this.nh=()=>this.hh(),this.oh=[],this.rh=[],this.ah=null,this.lh=[],this.uh=new Set,this.dh=-1,this.wh=new Map,this.fh=1,this.cn=!1,this.ph=0,this.mh=1,this.yh=0,this.gh="HRTF",this.bh="inverse",this._h=600,this.Sh=1e4,this.Oh=1,this.kh=[0,0,0],this.Ph=[0,0,-1,0,1,0],this.Ch=!1,this.Mh=!1,this.Rh=this.h.Yi("audio/webm; codecs=opus"),this.xh=new Map,this.Th=new Set,this.Ih=!1,this.Ah=!1,this.Gh="",this.Eh=null,self.C3Audio_OnMicrophoneStream=(t,s)=>this.Dh(t,s),this.Fh=null,self.C3Audio_GetOutputStream=()=>this.Wh(),(self.C3Audio_DOMInterface=this).I([["create-audio-context",t=>this.Lh(t)],["play",t=>this.Uh(t)],["stop",t=>this.Hh(t)],["stop-all",()=>this.Bh()],["set-paused",t=>this.Vh(t)],["set-volume",t=>this.jh(t)],["fade-volume",t=>this.Nh(t)],["set-master-volume",t=>this.zh(t)],["set-muted",t=>this.$h(t)],["set-silent",t=>this.qh(t)],["set-looping",t=>this.Yh(t)],["set-playback-rate",t=>this.Xh(t)],["set-stereo-pan",t=>this.Jh(t)],["seek",t=>this.Kh(t)],["preload",t=>this.Zh(t)],["unload",t=>this.Qh(t)],["unload-all",()=>this.so()],["set-suspended",t=>this.io(t)],["add-effect",t=>this.eo(t)],["set-effect-param",t=>this.no(t)],["remove-effects",t=>this.ho(t)],["tick",t=>this.oo(t)],["load-state",t=>this.ro(t)],["offline-render-audio",t=>this.ao(t)],["offline-render-finish",()=>this.co()]])}async Lh(t){if(t.usePlayMusicAsSoundWorkaround&&(this.Ch=!0),this.ph=t.timeScaleMode,this.gh=["equalpower","HRTF","soundfield"][t.panningModel],this.bh=["linear","inverse","exponential"][t.distanceModel],this._h=t.refDistance,this.Sh=t.maxDistance,this.Oh=t.rolloffFactor,this.h.Gi())this.Ch=!0,this.th=new OfflineAudioContext({numberOfChannels:2,sampleRate:48e3,length:Math.ceil(48e3*this.h.Ki())});else{const i={latencyHint:t.latencyHint};if(this.lo()||(i.sampleRate=48e3),"undefined"!=typeof AudioContext)this.th=new AudioContext(i);else{if("undefined"==typeof webkitAudioContext)throw new Error("Web Audio API not supported");this.th=new webkitAudioContext(i)}this.uo(),this.th.onstatechange=()=>{"running"!==this.th.state&&this.uo(),this.v("audiocontext-state",{audioContextState:this.th.state})}}this.sh=this.th.createGain(),this.sh.connect(this.th.destination);const s=t.listenerPos;this.kh[0]=s[0],this.kh[1]=s[1],this.kh[2]=s[2],this.th.listener.setPosition(s[0],s[1],s[2]),this.th.listener.setOrientation(...this.Ph),self.C3_GetAudioContextCurrentTime=()=>this.do();try{await Promise.all(t.preloadList.map(t=>this.wo(t.originalUrl,t.url,t.type,!1)))}catch(t){console.error("[Construct] Preloading sounds failed: ",t)}return{sampleRate:this.th.sampleRate,audioContextState:this.th.state,outputLatency:this.th.outputLatency||0}}uo(){this.eh||(this.ih=!1,window.addEventListener("pointerup",this.nh,!0),window.addEventListener("touchend",this.nh,!0),window.addEventListener("click",this.nh,!0),window.addEventListener("keydown",this.nh,!0),this.eh=!0)}fo(){this.eh&&(this.ih=!0,window.removeEventListener("pointerup",this.nh,!0),window.removeEventListener("touchend",this.nh,!0),window.removeEventListener("click",this.nh,!0),window.removeEventListener("keydown",this.nh,!0),this.eh=!1)}hh(){if(!this.ih){const t=this.th,s=("suspended"===t.state&&t.resume&&t.resume(),t.createBuffer(1,220,22050)),i=t.createBufferSource();i.buffer=s,i.connect(t.destination),i.start(0),"running"===t.state&&this.fo()}}po(s,t){for(const i of t){let t=!1;for(const e of s)if(self.Qn.mo(e,i)){t=!0;break}if(!t)return!1}return!0}yo(){return this.th}do(){return this.th.currentTime}vo(){return this.sh}["GetAudioContextExtern"](){return this.yo()}["GetDestinationNodeExtern"](){return this.vo()}bo(t){const s=this.xh.get(t.toLowerCase());return s?s[0]._o():this.vo()}So(t,s){t=t.toLowerCase();let i=this.xh.get(t);i||(i=[],this.xh.set(t,i)),s.Oo(i.length),s.ko(t),i.push(s),this.Po(t)}Po(t){t=t.toLowerCase();let s=this.vo();const i=this.xh.get(t);if(i&&i.length){s=i[0]._o();for(let t=0,s=i.length;t<s;++t){const e=i[t];t+1===s?e.Co(this.vo()):e.Co(i[t+1]._o())}}for(const n of this.Mo(t))n.Ro(s);this.Eh&&this.Gh===t&&(this.Eh.disconnect(),this.Eh.connect(s))}xo(){return this.fh}To(){return this.cn}Io(){return this.ph}Ao(){return this.mh}Go(){return this.yh}Eo(){return this.Ch}lo(){return this.Rh}Do(){this.Mh=!0}Fo(){return this.gh}Wo(){return this.bh}Lo(){return this._h}Uo(){return this.Sh}Ho(){return this.Oh}Bo(i,t){return t?this.h.Xi(i).then(t=>{const s=this.th.createBuffer(1,t.length,48e3),i=s.getChannelData(0);return i.set(t),s}):new Promise((t,s)=>{this.th.decodeAudioData(i,t,s)})}ji(t){this.h.ji(t)}Ni(t){this.h.Ni(t)}Vo(i){let e=0;for(let t=0,s=this.rh.length;t<s;++t){const n=this.rh[t];(this.rh[e]=n).jo()===i?n.it():++e}this.rh.length=e}No(){let i=0;for(let t=0,s=this.oh.length;t<s;++t){const e=this.oh[t];(this.oh[i]=e).zo()?e.it():++i}this.oh.length=i}*$o(t){if(0<t.length)for(const s of this.rh)this.po(s.qo(),t)&&(yield s);else this.ah&&!this.ah.Yo()&&(yield this.ah)}*Mo(t){if(t)for(const s of this.rh)self.Qn.mo(s.Xo(),t)&&(yield s);else this.ah&&!this.ah.Yo()&&(yield this.ah)}async wo(t,s,i,e,n){for(const o of this.oh)if(o.Jo()===s)return await o.Ko(),o;if(n)return null;e&&(this.Ch||this.Mh)&&this.No();const h=self.Qo.Zo(this,t,s,i,e);return this.oh.push(h),await h.Ko(),this.uh.has(t)||(this.v("buffer-metadata",{originalUrl:t,duration:h.tr()}),this.uh.add(t)),h}async sr(t,s,i,e,n){for(const r of this.rh)if(r.Jo()===s&&(r.ir()||n))return r.er(e),r;const h=await this.wo(t,s,i,n),o=h.nr(e);return this.rh.push(o),o}hr(t){const i=t.join(" ");let e=this.wh.get(i);if(!e){let s=null;const n=new Promise(t=>s=t);e={rr:0,promise:n,resolve:s},this.wh.set(i,e)}e.rr++}ar(t){const s=t.join(" "),i=this.wh.get(s);if(!i)throw new Error("expected pending tag");i.rr--,0===i.rr&&(i.resolve(),this.wh.delete(s))}cr(t){const s=(0===t.length?this.lh:t).join(" "),i=this.wh.get(s);return i?i.promise:Promise.resolve()}lr(){if(0<this.Th.size)this.D();else for(const t of this.rh)if(t.ur())return void this.D()}m(){for(const i of this.Th)i.m();const t=this.do();for(const e of this.rh)e.m(t);const s=this.rh.filter(t=>t.ur()).map(t=>t.dr());this.v("state",{tickCount:this.dh,outputLatency:this.th.outputLatency||0,audioInstances:s,analysers:[...this.Th].map(t=>t.wr())}),0===s.length&&0===this.Th.size&&this.W()}pr(t,s,i){this.v("trigger",{type:t,tags:s,aiid:i})}async Uh(t){const s=t.originalUrl,i=t.url,e=t.type,n=t.isMusic,h=t.tags,o=t.isLooping,r=t.vol,a=t.pos,c=t.panning,l=t.stereoPan;let u=t.off;if(0<u&&!t.trueClock)if(this.th.getOutputTimestamp){const d=this.th.getOutputTimestamp();u=u-d.performanceTime/1e3+d.contextTime}else u=u-performance.now()/1e3+this.th.currentTime;this.lh=h.slice(0),this.hr(h);try{this.ah=await this.sr(s,i,e,h,n),c?(this.ah.mr(!0),this.ah.yr(c.x,c.y,c.z,c.angle,c.innerAngle,c.outerAngle,c.outerGain),c.hasOwnProperty("uid")&&this.ah.gr(c.uid)):"number"==typeof l&&0!==l?(this.ah.vr(!0),this.ah.br(l)):(this.ah.mr(!1),this.ah.vr(!1)),this.ah.Play(o,r,a,u)}catch(t){return void console.error("[Construct] Audio: error starting playback: ",t)}finally{this.ar(h)}this.D()}Hh(t){const s=t.tags;for(const i of this.$o(s))i._r()}Bh(){for(const t of this.rh)t._r()}Vh(t){const s=t.tags,i=t.paused;for(const e of this.$o(s))i?e.Sr():e.Or();this.lr()}jh(t){const s=t.tags,i=t.vol;for(const e of this.$o(s))e.kr(i)}Jh(t){const s=t.tags,i=t.p;for(const e of this.$o(s))e.vr(!0),e.br(i)}async Nh(t){const s=t.tags,i=t.vol,e=t.duration,n=t.stopOnEnd;await this.cr(s);for(const h of this.$o(s))h.Pr(i,e,n);this.lr()}zh(t){this.fh=t.vol,this.sh.gain.value=this.fh}$h(t){const s=t.tags,i=t.isMuted;for(const e of this.$o(s))e.Cr(i)}qh(t){this.cn=t.isSilent,this.h.$i(this.cn);for(const s of this.rh)s.Mr()}Yh(t){const s=t.tags,i=t.isLooping;for(const e of this.$o(s))e.Rr(i)}async Xh(t){const s=t.tags,i=t.rate;await this.cr(s);for(const e of this.$o(s))e.Tr(i)}async Kh(t){const s=t.tags,i=t.pos;await this.cr(s);for(const e of this.$o(s))e.Ir(i)}async Zh(t){const s=t.originalUrl,i=t.url,e=t.type,n=t.isMusic;try{await this.sr(s,i,e,"",n)}catch(t){console.error("[Construct] Audio: error preloading: ",t)}}async Qh(t){const s=t.url,i=t.type,e=t.isMusic,n=await this.wo("",s,i,e,!0);if(n){n.it();const h=this.oh.indexOf(n);-1!==h&&this.oh.splice(h,1)}}so(){for(const t of this.oh)t.it();this.oh.length=0}io(t){const s=t.isSuspended;!s&&this.th.resume&&this.th.resume();for(const i of this.rh)i.Ar(s);s&&this.th.suspend&&this.th.suspend()}oo(t){if(this.mh=t.timeScale,this.yh=t.gameTime,this.dh=t.tickCount,0!==this.ph)for(const e of this.rh)e.Gr();const s=t.listenerPos,i=(!s||this.kh[0]===s[0]&&this.kh[1]===s[1]&&this.kh[2]===s[2]||(this.kh[0]=s[0],this.kh[1]=s[1],this.kh[2]=s[2],this.th.listener.setPosition(s[0],s[1],s[2])),t.listenerOrientation);if(i&&(this.Ph[0]!==i[0]||this.Ph[1]!==i[1]||this.Ph[2]!==i[2]||this.Ph[3]!==i[3]||this.Ph[4]!==i[4]||this.Ph[5]!==i[5])){for(let t=0;t<6;++t)this.Ph[t]=i[t];this.th.listener.setOrientation(...this.Ph)}for(const n of t.instPans){const h=n.uid;for(const o of this.rh)o.Er()===h&&o.Dr(n.x,n.y,n.z,n.angle)}}async eo(t){const s=t.type,i=t.hasOwnProperty("tags")?t.tags:[t.tag],e=t.params;let n,h;if("convolution"===s)try{h=await this.wo(t.bufferOriginalUrl,t.bufferUrl,t.bufferType,!1)}catch(t){return void console.log("[Construct] Audio: error loading convolution: ",t)}for(const o of i){if("filter"===s)n=new self.Fr(this,...e);else if("delay"===s)n=new self.Wr(this,...e);else if("convolution"===s)(n=new self.Ur(this,h.Hr(),...e)).Lr(t.bufferOriginalUrl,t.bufferUrl,t.bufferType);else if("flanger"===s)n=new self.Br(this,...e);else if("phaser"===s)n=new self.Vr(this,...e);else if("gain"===s)n=new self.jr(this,...e);else if("stereopan"===s)n=new self.Nr(this,...e);else if("tremolo"===s)n=new self.zr(this,...e);else if("ringmod"===s)n=new self.$r(this,...e);else if("distortion"===s)n=new self.qr(this,...e);else if("compressor"===s)n=new self.Yr(this,...e);else{if("analyser"!==s)throw new Error("invalid effect type");n=new self.Xr(this,...e)}this.So(o,n)}this.Jr()}no(t){const s=t.tags,i=t.index,e=t.param,n=t.value,h=t.ramp,o=t.time;for(const r of s){const a=this.xh.get(r.toLowerCase());!a||i<0||i>=a.length||a[i].Kr(e,n,h,o)}this.Jr()}ho(t){const s=t.tags;for(const i of s){const e=i.toLowerCase(),n=this.xh.get(e);if(!n||!n.length)return;for(const h of n)h.it();this.xh.delete(e),this.Po(e)}}Zr(t){this.Th.add(t),this.lr()}Qr(t){this.Th.delete(t)}Jr(){this.Ih||(this.Ih=!0,Promise.resolve().then(()=>this.ta()))}ta(){const t={};for(const[s,i]of this.xh)t[s]=i.map(t=>t.dr());this.v("fxstate",{fxstate:t}),this.Ih=!1}async ro(t){const s=t.saveLoadMode;if(3!==s){const h=[];for(const o of this.rh)o.zo()&&1===s||!o.zo()&&2===s?h.push(o):o.it();this.rh=h}for(const r of this.xh.values())for(const a of r)a.it();this.xh.clear(),this.mh=t.timeScale,this.yh=t.gameTime;const i=t.listenerPos,e=(this.kh[0]=i[0],this.kh[1]=i[1],this.kh[2]=i[2],this.th.listener.setPosition(i[0],i[1],i[2]),t.listenerOrientation);if(Array.isArray(e)){for(let t=0;t<6;++t)this.Ph[t]=e[t];this.th.listener.setOrientation(...this.Ph)}this.cn=t.isSilent,this.h.$i(this.cn),this.fh=t.masterVolume,this.sh.gain.value=this.fh;const n=[];for(const c of Object.values(t.effects))n.push(Promise.all(c.map(t=>this.eo(t))));await Promise.all(n),await Promise.all(t.playing.map(t=>this.sa(t,s))),this.lr()}async sa(s,i){if(3!==i){const e=s.bufferOriginalUrl,n=s.bufferUrl,h=s.bufferType,o=s.isMusic,r=s.tags,a=s.isLooping,c=s.volume,l=s.playbackTime;if((!o||1!==i)&&(o||2!==i)){let t=null;try{t=await this.sr(e,n,h,r,o)}catch(i){return void console.error("[Construct] Audio: error loading audio state: ",i)}t.ia(s.pan),t.ea(s.stereoPan),t.Play(a,c,l,0),s.isPlaying||t.Sr(),t.na(s)}}}Dh(t,s){this.Eh&&this.Eh.disconnect(),this.Gh=s.toLowerCase(),this.Eh=this.th.createMediaStreamSource(t),this.Eh.connect(this.bo(this.Gh))}Wh(){return this.Fh||(this.Fh=this.th.createMediaStreamDestination(),this.sh.connect(this.Fh)),this.Fh.stream}async ao(t){try{const s=t.time,i=this.th.suspend(s);this.Ah?this.th.resume():(this.th.startRendering().then(t=>this.ha(t)).catch(t=>this.oa(t)),this.Ah=!0),await i}catch(t){this.oa(t)}}co(){this.th.resume()}ha(i){const e=[];for(let t=0,s=i.numberOfChannels;t<s;++t){const n=i.getChannelData(t);e.push(n.buffer)}this.h._("runtime","offline-audio-render-completed",{duration:i.duration,length:i.length,numberOfChannels:i.numberOfChannels,sampleRate:i.sampleRate,channelData:e},null,e)}oa(t){console.error("[Audio] Offline rendering error: ",t)}static mo(t,s){return t===s||t.normalize().toLowerCase()===s.normalize().toLowerCase()}static ra(t){return t*u5}static aa(t){return Math.pow(10,t/20)}static ca(t){return Math.max(Math.min(self.Qn.aa(t),1),0)}static la(t){return Math.log(t)/Math.log(10)*20}static ua(t){return self.Qn.la(Math.max(Math.min(t,1),0))}static da(t,s){return 1-Math.exp(-s*t)}},self.Qt.Ui(self.Qn)}self.Qo=class{constructor(t,s,i,e,n){this.wa=t,this.fa=s,this.pa=i,this.ma=e,this.ya=n,this.ga="",this.va="not-loaded",this.ba=null}it(){this.va="not-loaded",this.wa=null,this.ba=null}static Zo(t,s,i,e,n){const h="audio/webm; codecs=opus"===e&&!t.lo();return n&&h&&t.Do(),!n||t.Eo()||h?new self._a(t,s,i,e,n,h):new self.Sa(t,s,i,e,n)}nr(t){return new("html5"===this.ga?self.Oa:self.ka)(this.wa,this,t)}Pa(){}Ko(){return this.ba||(this.ba=this.Pa()),this.ba}Ca(){}Ma(){}Ra(){return"failed"===this.va}yo(){return this.wa.yo()}xa(){return this.ga}Ta(){return this.fa}Jo(){return this.pa}Ia(){return this.ma}zo(){return this.ya}tr(){}},self.Sa=class extends self.Qo{constructor(t,s,i,e,n){super(t,s,i,e,n),this.ga="html5",this.Aa=new Audio,this.Aa.crossOrigin="anonymous",this.Aa.autoplay=!1,this.Aa.preload="auto",this.Ga=null,this.Ea=null,this.Da=!1,this.Aa.addEventListener("canplaythrough",()=>this.Da=!0),this.Fa=this.yo().createGain(),this.Wa=null,this.Aa.addEventListener("canplay",()=>{this.Ga&&(this.va="loaded",this.Ga(),this.Ga=null,this.Ea=null),!this.Wa&&this.Aa&&(this.Wa=this.yo().createMediaElementSource(this.Aa),this.Wa.connect(this.Fa))}),this.onended=null,this.Aa.addEventListener("ended",()=>{this.onended&&this.onended()}),this.Aa.addEventListener("error",t=>this.La(t))}it(){this.wa.Vo(this),this.Fa.disconnect(),this.Fa=null,this.Wa.disconnect(),this.Wa=null,this.Aa&&!this.Aa.paused&&this.Aa.pause(),this.onended=null,this.Aa=null,super.it()}Pa(){return this.va="loading",new Promise((t,s)=>{this.Ga=t,this.Ea=s,this.Aa.src=this.pa})}La(t){console.error(`[Construct] Audio '${this.pa}' error: `,t),this.Ea&&(this.va="failed",this.Ea(t),this.Ga=null,this.Ea=null)}Ca(){const t=4<=this.Aa.readyState;return t&&(this.Da=!0),t||this.Da}Ma(){return this.Ca()}Ua(){return this.Aa}Ha(){return this.Fa}tr(){return this.Aa.duration}},self._a=class extends self.Qo{constructor(t,s,i,e,n,h){super(t,s,i,e,n),this.ga="webaudio",this.Ba=null,this.Va=null,this.ja=!!h}it(){this.wa.Vo(this),this.Ba=null,this.Va=null,super.it()}async Na(){if(this.Ba)return this.Ba;const t=this.wa.A();if("cordova"===t.$s()&&t.Qi(this.pa)&&t.qs())this.Ba=await t.Ii(this.pa);else if("playable-ad-single-file"===t.$s()&&t.Qi(this.pa)){const s=t._PlayableAdFetchBlob(this.pa);this.Ba=await s.arrayBuffer()}else{const i=await fetch(this.pa);if(!i.ok)throw new Error(`error fetching audio data: ${i.status} `+i.statusText);this.Ba=await i.arrayBuffer()}}async za(){if(this.Va)return this.Va;this.Va=await this.wa.Bo(this.Ba,this.ja),this.Ba=null}async Pa(){try{this.va="loading",await this.Na(),await this.za(),this.va="loaded"}catch(t){this.va="failed",console.error(`[Construct] Failed to load audio '${this.pa}': `,t)}}Ca(){return!(!this.Ba&&!this.Va)}Ma(){return!!this.Va}Hr(){return this.Va}tr(){return this.Va?this.Va.duration:0}};{let n=0;self.$a=class{constructor(t,s,i){this.wa=t,this.qa=s,this.Ya=i,this.Xa=n++,this.Ja=this.yo().createGain(),this.Ja.connect(this.vo()),this.Ka=null,this.Za=!1,this.Qa=[0,0,0],this.tc=[0,0,0],this.sc=[0,0,0],this.ic=null,this.ec=!1,this.nc=0,this.hc=!0,this.oc=!1,this.rc=!1,this.ac=!1,this.cc=1,this.lc=!1,this.uc=1;const e=this.wa.Io();this.dc=1===e&&!this.zo()||2===e,this.wc=-1,this.fc=-1,this.mc=!1}it(){this.wa=null,this.qa=null,this.Ka&&(this.Ka.disconnect(),this.Ka=null),this.ic&&(this.ic.disconnect(),this.ic=null),this.Ja.disconnect(),this.Ja=null}yo(){return this.wa.yo()}er(t){this.Ya=t}qo(){return this.Ya}Xo(){return 0<this.Ya.length?this.Ya[0]:""}vo(){return this.wa.bo(this.Xo())}yc(){return this.dc?this.wa.Go():performance.now()/1e3}Ta(){return this.qa.Ta()}Jo(){return this.qa.Jo()}Ia(){return this.qa.Ia()}jo(){return this.qa}zo(){return this.qa.zo()}vc(){return this.Xa}Yo(){}ir(){}IsPlaying(){return!this.hc&&!this.oc&&!this.Yo()}ur(){return!this.hc&&!this.Yo()}bc(){}tr(t){let s=this.qa.tr();return t&&(s/=this.uc||.001),s}Play(t,s,i,e){}_r(){}Sr(){}_c(){return this.oc}Or(){}kr(t){this.cc=t,this.Ja.gain.cancelScheduledValues(0),this.fc=-1,this.Ja.gain.value=this.Sc()}Pr(t,s,i){if(!this.Oc()){const e=this.Ja.gain,n=(e.cancelScheduledValues(0),this.wa.do()),h=n+s;e.setValueAtTime(e.value,n),e.linearRampToValueAtTime(t,h),this.cc=t,this.fc=h,this.mc=i}}kc(){this.kr(this.cc)}m(t){-1!==this.fc&&t>=this.fc&&(this.fc=-1,this.mc&&this._r(),this.wa.pr("fade-ended",this.Ya,this.Xa))}Sc(){const t=this.cc;return isFinite(t)?t:0}Cr(t){this.lc!==(t=!!t)&&(this.lc=t,this.Mr())}Oc(){return this.lc}To(){return this.wa.To()}Mr(){}Rr(t){}Pc(){return this.ac}Tr(t){this.uc!==t&&(this.uc=t,this.Gr())}Gr(){}Cc(){return this.uc}Ir(t){}Ar(t){}mr(t){this.Za!==(t=!!t)&&(this.Za=t,(this.Za?(this.vr(!1),this.Ka||(this.Ka=this.yo().createPanner(),this.Ka.panningModel=this.wa.Fo(),this.Ka.distanceModel=this.wa.Wo(),this.Ka.refDistance=this.wa.Lo(),this.Ka.maxDistance=this.wa.Uo(),this.Ka.rolloffFactor=this.wa.Ho()),this.Ja.disconnect(),this.Ja.connect(this.Ka),this.Ka):(this.Ka.disconnect(),this.Ja.disconnect(),this.Ja)).connect(this.vo()))}yr(t,s,i,e,n,h,o){if(this.Za){this.Dr(t,s,i,e);const r=self.Qn.ra;this.sc[0]!==r(n)&&(this.sc[0]=r(n),this.Ka.coneInnerAngle=r(n)),this.sc[1]!==r(h)&&(this.sc[1]=r(h),this.Ka.coneOuterAngle=r(h)),this.sc[2]!==o&&(this.sc[2]=o,this.Ka.coneOuterGain=o)}}Dr(t,s,i,e){if(this.Za){const n=this.Qa,h=this.tc,o=Math.cos(e),r=Math.sin(e);n[0]===t&&n[1]===s&&n[2]===i||(n[0]=t,n[1]=s,n[2]=i,this.Ka.setPosition(...n)),h[0]===o&&h[1]===r&&0===h[2]||(h[0]=o,h[1]=r,h[2]=0,this.Ka.setOrientation(...h))}}vr(t){this.ec!==(t=!!t)&&(this.ec=t,(this.ec?(this.mr(!1),this.ic=this.yo().createStereoPanner(),this.Ja.disconnect(),this.Ja.connect(this.ic),this.ic):(this.ic.disconnect(),this.ic=null,this.Ja.disconnect(),this.Ja)).connect(this.vo()))}br(t){this.ec&&this.nc!==t&&(this.ic.pan.value=t,this.nc=t)}gr(t){this.wc=t}Er(){return this.wc}Mc(){}Ro(t){const s=this.ic||this.Ka||this.Ja;s.disconnect(),s.connect(t)}dr(){return{aiid:this.vc(),tags:this.Ya,duration:this.tr(),volume:-1===this.fc?this.cc:this.Ja.gain.value,isPlaying:this.IsPlaying(),playbackTime:this.bc(),playbackRate:this.Cc(),uid:this.wc,bufferOriginalUrl:this.Ta(),bufferUrl:"",bufferType:this.Ia(),isMusic:this.zo(),isLooping:this.Pc(),isMuted:this.Oc(),resumePosition:this.Mc(),pan:this.Rc(),stereoPan:this.xc()}}na(t){this.Tr(t.playbackRate),this.Cr(t.isMuted)}Rc(){if(!this.Ka)return null;const t=this.Ka;return{pos:this.Qa,orient:this.tc,cia:t.coneInnerAngle,coa:t.coneOuterAngle,cog:t.coneOuterGain,uid:this.wc}}ia(t){if(t){this.mr(!0);const s=this.Ka,i=t.pos,e=(this.Qa[0]=i[0],this.Qa[1]=i[1],this.Qa[2]=i[2],t.orient);this.tc[0]=e[0],this.tc[1]=e[1],this.tc[2]=e[2],s.setPosition(...this.Qa),s.setOrientation(...this.tc),this.sc[0]=t.cia,this.sc[1]=t.coa,this.sc[2]=t.cog,s.coneInnerAngle=t.cia,s.coneOuterAngle=t.coa,s.coneOuterGain=t.cog,this.wc=t.uid}else this.mr(!1)}xc(){return this.ic?this.nc:null}ea(t){"number"!=typeof t?this.vr(!1):(this.vr(!0),this.br(t))}}}self.Oa=class extends self.$a{constructor(t,s,i){super(t,s,i),this.qa.Ha().connect(this.Ja),this.qa.onended=()=>this.Tc()}it(){this._r(),this.qa.Ha().disconnect(),super.it()}Ua(){return this.qa.Ua()}Tc(){this.hc=!0,this.wc=-1,this.wa.pr("ended",this.Ya,this.Xa)}Yo(){return this.Ua().ended}ir(){return!!this.hc||this.Yo()}bc(){let t=this.Ua().currentTime;return this.ac?t:Math.min(t,this.tr())}Play(t,s,i,e){const n=this.Ua();if(1!==n.playbackRate&&(n.playbackRate=1),n.loop!==t&&(n.loop=t),this.kr(s),this.lc=!1,n.muted&&(n.muted=!1),n.currentTime!==i)try{n.currentTime=i}catch(t){console.warn(`[Construct] Exception seeking audio '${this.qa.Jo()}' to position '${i}': `,t)}this.wa.ji(n),this.hc=!1,this.oc=!1,this.ac=t,this.uc=1}_r(){const t=this.Ua();t.paused||t.pause(),this.wa.Ni(t),this.hc=!0,this.oc=!1,this.wc=-1}Sr(){if(!(this.oc||this.hc||this.Yo())){const t=this.Ua();t.paused||t.pause(),this.wa.Ni(t),this.oc=!0}}Or(){!this.oc||this.hc||this.Yo()||(this.wa.ji(this.Ua()),this.oc=!1)}Mr(){this.Ua().muted=this.lc||this.To()}Rr(t){this.ac!==(t=!!t)&&(this.ac=t,this.Ua().loop=t)}Gr(){let s=this.uc;this.dc&&(s*=this.wa.Ao());try{this.Ua().playbackRate=s}catch(t){console.warn(`[Construct] Unable to set playback rate '${s}':`,t)}}Ir(s){if(!this.hc&&!this.Yo())try{this.Ua().currentTime=s}catch(t){console.warn(`[Construct] Error seeking audio to '${s}': `,t)}}Mc(){return this.bc()}Ar(t){t?this.IsPlaying()?(this.Ua().pause(),this.rc=!0):this.rc=!1:this.rc&&(this.wa.ji(this.Ua()),this.rc=!1)}},self.ka=class extends self.$a{constructor(t,s,i){super(t,s,i),this.Ic=null,this.Ac=t=>this.Tc(t),this.Gc=!0,this.Ec=null,this.Dc=0,this.Fc=0,this.Wc=0,this.Lc=1}it(){this._r(),this.Uc(),this.Ac=null,super.it()}Uc(){this.Ic&&(this.Ic.onended=null,this.Ic.disconnect(),this.Ic.buffer=null),this.Ic=null,this.Ec=null}Tc(t){this.oc||this.rc||t.target===this.Ec&&(this.Gc=!0,this.hc=!0,this.wc=-1,this.Uc(),this.wa.pr("ended",this.Ya,this.Xa))}Yo(){return!(!this.hc&&this.Ic&&this.Ic.loop||this.oc)&&this.Gc}ir(){return!(this.Ic&&!this.hc)||this.Yo()}bc(){let t=0;return t=this.oc?this.Wc:this.Fc+(this.yc()-this.Dc)*this.uc,this.ac?t:Math.min(t,this.tr())}Play(t,s,i,e){this.lc=!1,this.Lc=1,this.kr(s),this.Uc(),this.Ic=this.yo().createBufferSource(),this.Ic.buffer=this.qa.Hr(),this.Ic.connect(this.Ja),this.Ec=this.Ic,this.Ic.onended=this.Ac,this.Ic.loop=t,this.Ic.start(e,i),this.Gc=!1,this.hc=!1,this.oc=!1,this.ac=t,this.uc=1,this.Dc=this.yc(),this.Fc=i}_r(){if(this.Ic)try{this.Ic.stop(0)}catch(t){}this.hc=!0,this.oc=!1,this.wc=-1}Sr(){this.oc||this.hc||this.Yo()||(this.Wc=this.bc(),this.ac&&(this.Wc%=this.tr()),this.oc=!0,this.Ic.stop(0))}Or(){!this.oc||this.hc||this.Yo()||(this.Uc(),this.Ic=this.yo().createBufferSource(),this.Ic.buffer=this.qa.Hr(),this.Ic.connect(this.Ja),this.Ec=this.Ic,this.Ic.onended=this.Ac,this.Ic.loop=this.ac,this.kc(),this.Gr(),this.Ic.start(0,this.Wc),this.Dc=this.yc(),this.Fc=this.Wc,this.oc=!1)}Sc(){return super.Sc()*this.Lc}Mr(){this.Lc=this.lc||this.To()?0:1,this.kc()}Rr(t){this.ac!==(t=!!t)&&(this.ac=t,this.Ic)&&(this.Ic.loop=t)}Gr(){let t=this.uc;this.dc&&(t*=this.wa.Ao()),this.Ic&&(this.Ic.playbackRate.value=t)}Ir(t){this.hc||this.Yo()||(this.oc?this.Wc=t:(this.Sr(),this.Wc=t,this.Or()))}Mc(){return this.Wc}Ar(t){t?this.IsPlaying()?(this.rc=!0,this.Wc=this.bc(),this.ac&&(this.Wc%=this.tr()),this.Ic.stop(0)):this.rc=!1:this.rc&&(this.Uc(),this.Ic=this.yo().createBufferSource(),this.Ic.buffer=this.qa.Hr(),this.Ic.connect(this.Ja),this.Ec=this.Ic,this.Ic.onended=this.Ac,this.Ic.loop=this.ac,this.kc(),this.Gr(),this.Ic.start(0,this.Wc),this.Dc=this.yc(),this.Fc=this.Wc,this.rc=!1)}na(t){super.na(t),this.Wc=t.resumePosition}};{class yj{constructor(t){this.wa=t,this.th=t.yo(),this.Hc=-1,this.Bc="",this.ma="",this.Vc=null}it(){this.th=null}Oo(t){this.Hc=t}jc(){return this.Hc}ko(t){this.Bc=t}Nc(){return this.Bc}zc(){return this.th.createGain()}_o(){}Co(t){}$c(t,s,i,e){if(t.cancelScheduledValues(0),0===e)t.value=s;else{const n=this.th.currentTime;switch(e+=n,i){case 0:t.setValueAtTime(s,e);break;case 1:t.setValueAtTime(t.value,n),t.linearRampToValueAtTime(s,e);break;case 2:t.setValueAtTime(t.value,n),t.exponentialRampToValueAtTime(s,e)}}}dr(){return{type:this.ma,tag:this.Bc,params:this.Vc}}}self.Fr=class extends yj{constructor(t,s,i,e,n,h,o){super(t),this.ma="filter",this.Vc=[s,i,e,n,h,o],this.qc=this.zc(),this.Yc=this.zc(),this.Yc.gain.value=o,this.Xc=this.zc(),this.Xc.gain.value=1-o,this.Jc=this.th.createBiquadFilter(),this.Jc.type=s,this.Jc.frequency.value=i,this.Jc.detune.value=e,this.Jc.Q.value=n,this.Jc.gain.vlaue=h,this.qc.connect(this.Jc),this.qc.connect(this.Xc),this.Jc.connect(this.Yc)}it(){this.qc.disconnect(),this.Jc.disconnect(),this.Yc.disconnect(),this.Xc.disconnect(),super.it()}Co(t){this.Yc.disconnect(),this.Yc.connect(t),this.Xc.disconnect(),this.Xc.connect(t)}_o(){return this.qc}Kr(t,s,i,e){switch(t){case 0:s=Math.max(Math.min(s/100,1),0),this.Vc[5]=s,this.$c(this.Yc.gain,s,i,e),this.$c(this.Xc.gain,1-s,i,e);break;case 1:this.Vc[1]=s,this.$c(this.Jc.frequency,s,i,e);break;case 2:this.Vc[2]=s,this.$c(this.Jc.detune,s,i,e);break;case 3:this.Vc[3]=s,this.$c(this.Jc.Q,s,i,e);break;case 4:this.Vc[4]=s,this.$c(this.Jc.gain,s,i,e)}}},self.Wr=class extends yj{constructor(t,s,i,e){super(t),this.ma="delay",this.Vc=[s,i,e],this.qc=this.zc(),this.Yc=this.zc(),this.Yc.gain.value=e,this.Xc=this.zc(),this.Xc.gain.value=1-e,this.Kc=this.zc(),this.Zc=this.th.createDelay(s),this.Zc.delayTime.value=s,this.Qc=this.zc(),this.Qc.gain.value=i,this.qc.connect(this.Kc),this.qc.connect(this.Xc),this.Kc.connect(this.Yc),this.Kc.connect(this.Zc),this.Zc.connect(this.Qc),this.Qc.connect(this.Kc)}it(){this.qc.disconnect(),this.Yc.disconnect(),this.Xc.disconnect(),this.Kc.disconnect(),this.Zc.disconnect(),this.Qc.disconnect(),super.it()}Co(t){this.Yc.disconnect(),this.Yc.connect(t),this.Xc.disconnect(),this.Xc.connect(t)}_o(){return this.qc}Kr(t,s,i,e){const n=self.Qn.ca;switch(t){case 0:s=Math.max(Math.min(s/100,1),0),this.Vc[2]=s,this.$c(this.Yc.gain,s,i,e),this.$c(this.Xc.gain,1-s,i,e);break;case 4:this.Vc[1]=n(s),this.$c(this.Qc.gain,n(s),i,e);break;case 5:this.Vc[0]=s,this.$c(this.Zc.delayTime,s,i,e)}}},self.Ur=class extends yj{constructor(t,s,i,e){super(t),this.ma="convolution",this.Vc=[i,e],this.tl="",this.sl="",this.il="",this.qc=this.zc(),this.Yc=this.zc(),this.Yc.gain.value=e,this.Xc=this.zc(),this.Xc.gain.value=1-e,this.el=this.th.createConvolver(),this.el.normalize=i,this.el.buffer=s,this.qc.connect(this.el),this.qc.connect(this.Xc),this.el.connect(this.Yc)}it(){this.qc.disconnect(),this.el.disconnect(),this.Yc.disconnect(),this.Xc.disconnect(),super.it()}Co(t){this.Yc.disconnect(),this.Yc.connect(t),this.Xc.disconnect(),this.Xc.connect(t)}_o(){return this.qc}Kr(t,s,i,e){0===t&&(s=Math.max(Math.min(s/100,1),0),this.Vc[1]=s,this.$c(this.Yc.gain,s,i,e),this.$c(this.Xc.gain,1-s,i,e))}Lr(t,s,i){this.tl=t,this.sl=s,this.il=i}dr(){const t=super.dr();return t.bufferOriginalUrl=this.tl,t.bufferUrl="",t.bufferType=this.il,t}},self.Br=class extends yj{constructor(t,s,i,e,n,h){super(t),this.ma="flanger",this.Vc=[s,i,e,n,h],this.qc=this.zc(),this.Xc=this.zc(),this.Xc.gain.value=1-h/2,this.Yc=this.zc(),this.Yc.gain.value=h/2,this.nl=this.zc(),this.nl.gain.value=n,this.Zc=this.th.createDelay(s+i),this.Zc.delayTime.value=s,this.hl=this.th.createOscillator(),this.hl.frequency.value=e,this.ol=this.zc(),this.ol.gain.value=i,this.qc.connect(this.Zc),this.qc.connect(this.Xc),this.Zc.connect(this.Yc),this.Zc.connect(this.nl),this.nl.connect(this.Zc),this.hl.connect(this.ol),this.ol.connect(this.Zc.delayTime),this.hl.start(0)}it(){this.hl.stop(0),this.qc.disconnect(),this.Zc.disconnect(),this.hl.disconnect(),this.ol.disconnect(),this.Xc.disconnect(),this.Yc.disconnect(),this.nl.disconnect(),super.it()}Co(t){this.Yc.disconnect(),this.Yc.connect(t),this.Xc.disconnect(),this.Xc.connect(t)}_o(){return this.qc}Kr(t,s,i,e){switch(t){case 0:s=Math.max(Math.min(s/100,1),0),this.Vc[4]=s,this.$c(this.Yc.gain,s/2,i,e),this.$c(this.Xc.gain,1-s/2,i,e);break;case 6:this.Vc[1]=s/1e3,this.$c(this.ol.gain,s/1e3,i,e);break;case 7:this.Vc[2]=s,this.$c(this.hl.frequency,s,i,e);break;case 8:this.Vc[3]=s/100,this.$c(this.nl.gain,s/100,i,e)}}},self.Vr=class extends yj{constructor(t,s,i,e,n,h,o){super(t),this.ma="phaser",this.Vc=[s,i,e,n,h,o],this.qc=this.zc(),this.Xc=this.zc(),this.Xc.gain.value=1-o/2,this.Yc=this.zc(),this.Yc.gain.value=o/2,this.Jc=this.th.createBiquadFilter(),this.Jc.type="allpass",this.Jc.frequency.value=s,this.Jc.detune.value=i,this.Jc.Q.value=e,this.hl=this.th.createOscillator(),this.hl.frequency.value=h,this.ol=this.zc(),this.ol.gain.value=n,this.qc.connect(this.Jc),this.qc.connect(this.Xc),this.Jc.connect(this.Yc),this.hl.connect(this.ol),this.ol.connect(this.Jc.frequency),this.hl.start(0)}it(){this.hl.stop(0),this.qc.disconnect(),this.Jc.disconnect(),this.hl.disconnect(),this.ol.disconnect(),this.Xc.disconnect(),this.Yc.disconnect(),super.it()}Co(t){this.Yc.disconnect(),this.Yc.connect(t),this.Xc.disconnect(),this.Xc.connect(t)}_o(){return this.qc}Kr(t,s,i,e){switch(t){case 0:s=Math.max(Math.min(s/100,1),0),this.Vc[5]=s,this.$c(this.Yc.gain,s/2,i,e),this.$c(this.Xc.gain,1-s/2,i,e);break;case 1:this.Vc[0]=s,this.$c(this.Jc.frequency,s,i,e);break;case 2:this.Vc[1]=s,this.$c(this.Jc.detune,s,i,e);break;case 3:this.Vc[2]=s,this.$c(this.Jc.Q,s,i,e);break;case 6:this.Vc[3]=s,this.$c(this.ol.gain,s,i,e);break;case 7:this.Vc[4]=s,this.$c(this.hl.frequency,s,i,e)}}},self.jr=class extends yj{constructor(t,s){super(t),this.ma="gain",this.Vc=[s],this.rl=this.zc(),this.rl.gain.value=s}it(){this.rl.disconnect(),super.it()}Co(t){this.rl.disconnect(),this.rl.connect(t)}_o(){return this.rl}Kr(t,s,i,e){const n=self.Qn.ca;4===t&&(this.Vc[0]=n(s),this.$c(this.rl.gain,n(s),i,e))}},self.Nr=class extends yj{constructor(t,s){super(t),this.ma="stereopan",this.Vc=[s],this.rl=this.th.createStereoPanner(),this.rl.pan.value=s}it(){this.rl.disconnect(),super.it()}Co(t){this.rl.disconnect(),this.rl.connect(t)}_o(){return this.rl}Kr(t,s,i,e){s=Math.min(Math.max(s/100,-1),1),9===t&&(this.Vc[0]=s,this.$c(this.rl.pan,s,i,e))}},self.zr=class extends yj{constructor(t,s,i){super(t),this.ma="tremolo",this.Vc=[s,i],this.rl=this.zc(),this.rl.gain.value=1-i/2,this.hl=this.th.createOscillator(),this.hl.frequency.value=s,this.ol=this.zc(),this.ol.gain.value=i/2,this.hl.connect(this.ol),this.ol.connect(this.rl.gain),this.hl.start(0)}it(){this.hl.stop(0),this.hl.disconnect(),this.ol.disconnect(),this.rl.disconnect(),super.it()}Co(t){this.rl.disconnect(),this.rl.connect(t)}_o(){return this.rl}Kr(t,s,i,e){switch(t){case 0:s=Math.max(Math.min(s/100,1),0),this.Vc[1]=s,this.$c(this.rl.gain,1-s/2,i,e),this.$c(this.ol.gain,s/2,i,e);break;case 7:this.Vc[0]=s,this.$c(this.hl.frequency,s,i,e)}}},self.$r=class extends yj{constructor(t,s,i){super(t),this.ma="ringmod",this.Vc=[s,i],this.qc=this.zc(),this.Yc=this.zc(),this.Yc.gain.value=i,this.Xc=this.zc(),this.Xc.gain.value=1-i,this.al=this.zc(),this.al.gain.value=0,this.hl=this.th.createOscillator(),this.hl.frequency.value=s,this.hl.connect(this.al.gain),this.hl.start(0),this.qc.connect(this.al),this.qc.connect(this.Xc),this.al.connect(this.Yc)}it(){this.hl.stop(0),this.hl.disconnect(),this.al.disconnect(),this.qc.disconnect(),this.Yc.disconnect(),this.Xc.disconnect(),super.it()}Co(t){this.Yc.disconnect(),this.Yc.connect(t),this.Xc.disconnect(),this.Xc.connect(t)}_o(){return this.qc}Kr(t,s,i,e){switch(t){case 0:s=Math.max(Math.min(s/100,1),0),this.Vc[1]=s,this.$c(this.Yc.gain,s,i,e),this.$c(this.Xc.gain,1-s,i,e);break;case 7:this.Vc[0]=s,this.$c(this.hl.frequency,s,i,e)}}},self.qr=class extends yj{constructor(t,s,i,e,n,h){super(t),this.ma="distortion",this.Vc=[s,i,e,n,h],this.qc=this.zc(),this.cl=this.zc(),this.ll=this.zc(),this.ul(e,n),this.Yc=this.zc(),this.Yc.gain.value=h,this.Xc=this.zc(),this.Xc.gain.value=1-h,this.dl=this.th.createWaveShaper(),this.wl=new Float32Array(65536),this.fl(s,i),this.dl.curve=this.wl,this.qc.connect(this.cl),this.qc.connect(this.Xc),this.cl.connect(this.dl),this.dl.connect(this.ll),this.ll.connect(this.Yc)}it(){this.qc.disconnect(),this.cl.disconnect(),this.dl.disconnect(),this.ll.disconnect(),this.Yc.disconnect(),this.Xc.disconnect(),super.it()}ul(t,s){this.cl.gain.value=t=t<.01?.01:t,this.ll.gain.value=Math.pow(1/t,.6)*s}fl(i,e){const n=32768;for(let s=0;s<n;++s){let t=s/n;t=this.pl(t,i,e),this.wl[n+s]=t,this.wl[n-s-1]=-t}}pl(t,s,i){const e=1.05*i*s,n=e-s,h=t<0?-1:1,o=t<0?-t:t;let r=o<s?o:s+n*self.Qn.da(o-s,1/n);return r*h}Co(t){this.Yc.disconnect(),this.Yc.connect(t),this.Xc.disconnect(),this.Xc.connect(t)}_o(){return this.qc}Kr(t,s,i,e){0===t&&(s=Math.max(Math.min(s/100,1),0),this.Vc[4]=s,this.$c(this.Yc.gain,s,i,e),this.$c(this.Xc.gain,1-s,i,e))}},self.Yr=class extends yj{constructor(t,s,i,e,n,h){super(t),this.ma="compressor",this.Vc=[s,i,e,n,h],this.rl=this.th.createDynamicsCompressor(),this.rl.threshold.value=s,this.rl.knee.value=i,this.rl.ratio.value=e,this.rl.attack.value=n,this.rl.release.value=h}it(){this.rl.disconnect(),super.it()}Co(t){this.rl.disconnect(),this.rl.connect(t)}_o(){return this.rl}Kr(t,s,i,e){}},self.Xr=class extends yj{constructor(t,s,i){super(t),this.ma="analyser",this.Vc=[s,i],this.rl=this.th.createAnalyser(),this.rl.fftSize=s,this.rl.smoothingTimeConstant=i,this.ml=new Float32Array(this.rl.frequencyBinCount),this.yl=new Uint8Array(s),this.gl=0,this.vl=0,this.wa.Zr(this)}it(){this.wa.Qr(this),this.rl.disconnect(),super.it()}m(){this.rl.getFloatFrequencyData(this.ml),this.rl.getByteTimeDomainData(this.yl);const t=this.rl.fftSize;let i=this.gl=0;for(let s=0;s<t;++s){let t=(this.yl[s]-128)/128;t<0&&(t=-t),this.gl<t&&(this.gl=t),i+=t*t}const s=self.Qn.ua;this.gl=s(this.gl),this.vl=s(Math.sqrt(i/t))}Co(t){this.rl.disconnect(),this.rl.connect(t)}_o(){return this.rl}Kr(t,s,i,e){}wr(){return{tag:this.Nc(),index:this.jc(),peak:this.gl,rms:this.vl,binCount:this.rl.frequencyBinCount,freqBins:this.ml}}}}{const ll="mouse",ml=class extends self.i{constructor(t){super(t,ll),this.I([["cursor",t=>this.bl(t)],["request-pointer-lock",t=>this._l(t)],["release-pointer-lock",()=>this.Sl()]]),document.addEventListener("pointerlockchange",t=>this.Ol()),document.addEventListener("pointerlockerror",t=>this.kl())}bl(t){document.documentElement.style.cursor=t}_l(t){this.h.Ns().requestPointerLock(t)}Sl(){document.exitPointerLock()}Ol(){this.v("pointer-lock-change",{"has-pointer-lock":!!document.pointerLockElement})}kl(){this.v("pointer-lock-error",{"has-pointer-lock":!!document.pointerLockElement})}};self.Qt.Ui(ml)}{let s=null,i=null;function elemsForSelector(t,s){if(t){if(s)return Array.from(document.querySelectorAll(t));{const i=document.querySelector(t);return i?[i]:[]}}return[document.documentElement]}function noop(){}window.addEventListener("beforeinstallprompt",t=>(t.preventDefault(),s=t,i&&i.Pl(),!1));const wl="browser",xl=class extends self.i{constructor(t){super(t,wl),this.Ms="",this.I([["get-initial-state",t=>this.Cl(t)],["ready-for-sw-messages",()=>this.Ml()],["alert",t=>this.Xe(t)],["close",()=>this.Rl()],["set-focus",t=>this.It(t)],["vibrate",t=>this.xl(t)],["lock-orientation",t=>this.Tl(t)],["unlock-orientation",()=>this.Il()],["navigate",t=>this.Al(t)],["request-fullscreen",t=>this.Gl(t)],["exit-fullscreen",()=>this.El()],["set-hash",t=>this.Dl(t)],["set-document-css-style",t=>this.Fl(t)],["get-document-css-style",t=>this.Wl(t)],["set-window-size",t=>this.Ll(t)],["set-window-position",t=>this.Ul(t)],["request-install",()=>this.Hl()],["set-warn-on-close",t=>this.Bl(t)]]),window.addEventListener("online",()=>this.Vl(!0)),window.addEventListener("offline",()=>this.Vl(!1)),window.addEventListener("hashchange",()=>this.jl()),this.Nl=t=>t.preventDefault(),document.addEventListener("backbutton",()=>this.zl())}g(){s?this.Pl():i=this,window.addEventListener("appinstalled",()=>this.$l())}Cl(t){return this.Ms=t.exportType,{location:location.toString(),isOnline:!!navigator.onLine,referrer:document.referrer,title:document.title,isCookieEnabled:!!navigator.cookieEnabled,screenWidth:screen.width,screenHeight:screen.height,windowOuterWidth:window.outerWidth,windowOuterHeight:window.outerHeight,isConstructArcade:void 0!==window.is_scirra_arcade}}Ml(){window.C3_RegisterSW&&window.OfflineClientInfo&&window.OfflineClientInfo.SetMessageCallback(t=>this.v("sw-message",t.data))}Pl(){this.v("install-available")}async Hl(){if(!s)return{result:"unavailable"};try{s.prompt();const t=await s.userChoice;return{result:t.outcome}}catch(t){return console.error("[Construct] Requesting install failed: ",t),{result:"failed"}}}$l(){this.v("app-installed")}Vl(t){this.v("online-state",{isOnline:t})}zl(){this.v("backbutton")}ql(){return"nwjs"===this.Ms?nw.Window.get():null}Xe(t){alert(t.message)}Rl(){navigator.app&&navigator.app.exitApp?navigator.app.exitApp():navigator.device&&navigator.device.exitApp?navigator.device.exitApp():self.nw?self.nw.App.quit():window.close()}It(t){const s=t.isFocus;if("nwjs"===this.Ms){const i=this.ql();s?i.focus():i.blur()}else s?window.focus():window.blur()}xl(t){navigator.vibrate&&navigator.vibrate(t.pattern)}Tl(t){const s=t.orientation;if(screen.orientation&&screen.orientation.lock)screen.orientation.lock(s).catch(t=>console.warn("[Construct] Failed to lock orientation: ",t));else try{let t=!1;screen.lockOrientation?t=screen.lockOrientation(s):screen.webkitLockOrientation?t=screen.webkitLockOrientation(s):screen.mozLockOrientation?t=screen.mozLockOrientation(s):screen.msLockOrientation&&(t=screen.msLockOrientation(s)),t||console.warn("[Construct] Failed to lock orientation")}catch(t){console.warn("[Construct] Failed to lock orientation: ",t)}}Il(){try{screen.orientation&&screen.orientation.unlock?screen.orientation.unlock():screen.unlockOrientation?screen.unlockOrientation():screen.webkitUnlockOrientation?screen.webkitUnlockOrientation():screen.mozUnlockOrientation?screen.mozUnlockOrientation():screen.msUnlockOrientation&&screen.msUnlockOrientation()}catch(t){}}Al(t){const s=t.type;if("back"===s)navigator.app&&navigator.app.backHistory?navigator.app.backHistory():window.history.back();else if("forward"===s)window.history.forward();else if("reload"===s)location.reload();else if("url"===s){const i=t.url,e=t.target,n=t.exportType;self.cordova&&self.cordova.InAppBrowser?self.cordova.InAppBrowser.open(i,"_system"):"preview"===n||"linux-cef"===n||this.h.Ts()?window.open(i,"_blank"):this._isConstructArcade||(2===e?window.top.location=i:1===e?window.parent.location=i:window.location=i)}else if("new-window"===s){const h=t.url,o=t.tag;self.cordova&&self.cordova.InAppBrowser?self.cordova.InAppBrowser.open(h,"_system"):window.open(h,o)}}Gl(s){if(this.h.Ts()||"macos-wkwebview"===this.Ms||"linux-cef"===this.Ms)self.Qt.Hi(!0),this.h.ei({type:"set-fullscreen",fullscreen:!0});else{const i={navigationUI:"auto"},e=s.navUI,n=(1===e?i.navigationUI="hide":2===e&&(i.navigationUI="show"),document.documentElement);let t;n.requestFullscreen?t=n.requestFullscreen(i):n.mozRequestFullScreen?t=n.mozRequestFullScreen(i):n.msRequestFullscreen?t=n.msRequestFullscreen(i):n.webkitRequestFullScreen&&(t=void 0!==Element.ALLOW_KEYBOARD_INPUT?n.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT):n.webkitRequestFullScreen()),t instanceof Promise&&t.catch(noop)}}El(){if(this.h.Ts()||"macos-wkwebview"===this.Ms||"linux-cef"===this.Ms)self.Qt.Hi(!1),this.h.ei({type:"set-fullscreen",fullscreen:!1});else{let t;document.exitFullscreen?t=document.exitFullscreen():document.mozCancelFullScreen?t=document.mozCancelFullScreen():document.msExitFullscreen?t=document.msExitFullscreen():document.webkitCancelFullScreen&&(t=document.webkitCancelFullScreen()),t instanceof Promise&&t.catch(noop)}}Dl(t){location.hash=t.hash}jl(){this.v("hashchange",{location:location.toString()})}Fl(t){const s=t.prop,i=t.value,e=t.selector,n=t["is-all"];try{const h=elemsForSelector(e,n);for(const t of h)s.startsWith("--")?t.style.setProperty(s,i):t.style[s]=i}catch(t){console.warn("[Browser] Failed to set style: ",t)}}Wl(t){const s=t.prop,i=t.selector;try{const e=document.querySelector(i);if(e){const n=window.getComputedStyle(e);return{isOk:!0,result:n.getPropertyValue(s)}}return{isOk:!1}}catch(t){return console.warn("[Browser] Failed to get style: ",t),{isOk:!1}}}Ll(t){window.resizeTo(t.windowWidth,t.windowHeight)}Ul(t){window.moveTo(t.windowX,t.windowY)}Bl(t){const s=t.enabled;s?window.addEventListener("beforeunload",this.Nl):window.removeEventListener("beforeunload",this.Nl)}};self.Qt.Ui(xl)}if(window.C3_Is_Supported){const Hm=!0;window.c3_runtimeInterface=new self.Qt({ss:Hm,vi:"workermain.js",runtimeScriptList:["scripts/c3main.js"],scriptFolder:"scripts/",exportType:"windows-webview2"})}